11 Commits

Author SHA1 Message Date
eyedeekay
98b94db696 fix NPE when using bare garlic with i2p logger wrapper 2025-08-06 16:22:13 -04:00
eyedeekay
65e43111b7 fix NPE when using bare garlic with i2p logger wrapper 2025-08-06 16:20:11 -04:00
idk
48e87d68a9 Merge pull request #2 from urgentquest/main
Utililize go i2p logger (revised)
2025-05-05 18:02:21 -04:00
Call me Phil
3f93dec9db Utililize go i2p logger (#1)
- Drop log.go in favor of using go-i2p/logger
- Fix an occurrence of ioutil deprecation. Bump go version to a recent one
2025-03-30 23:14:21 +00:00
eyedeekay
d537acfa66 add function for exmitting TLS config to consumers 2025-02-23 16:49:16 -05:00
eyedeekay
8b297d030a update and use external logger module 2024-11-21 18:48:44 -05:00
eyedeekay
daeaa91183 update modules 2024-11-16 16:25:24 -05:00
eyedeekay
ed7e6f56ae update release process 2024-11-16 16:23:33 -05:00
eyedeekay
982a496406 update module 2024-11-16 15:51:42 -05:00
eyedeekay
d7abd8af30 don't log in GetJoinedWD for now because it is called prior to 2024-11-16 15:50:58 -05:00
eyedeekay
0d05b3c3f7 update examples 2024-11-14 10:43:17 -05:00
14 changed files with 113 additions and 123 deletions

View File

@@ -12,7 +12,7 @@ import (
"log"
"net/http"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {
@@ -44,7 +44,7 @@ import (
"log"
"net/http"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {
@@ -135,7 +135,7 @@ import (
"log"
"net/http"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {
@@ -167,7 +167,7 @@ import (
"log"
"net/http"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {

View File

@@ -1,6 +1,6 @@
USER_GH=eyedeekay
VERSION=0.33.9
USER_GH=go-i2p
VERSION=0.33.92
CREDIT='contributors to this release: @hkh4n, @eyedeekay'
packagename=onramp

View File

@@ -1,6 +1,8 @@
onramp
======
[![Go Report Card](https://goreportcard.com/badge/github.com/go-i2p/onramp)](https://goreportcard.com/report/github.com/go-i2p/onramp)
High-level, easy-to-use listeners and clients for I2P and onion URL's from Go.
Provides only the most widely-used functions in a basic way. It expects nothing
from the users, an otherwise empty instance of the structs will listen and dial
@@ -12,9 +14,9 @@ This means that hidden services will maintain their identities, and that clients
will always have the same return addresses. If you don't want this behavior,
make sure to delete the "keystore" when your app closes or when your application
needs to cycle keys by calling the `Garlic.DeleteKeys()` or `Onion.DeleteKeys()`
function. For more information, check out the [godoc](http://pkg.go.dev/github.com/eyedeekay/onramp).
function. For more information, check out the [godoc](http://pkg.go.dev/github.com/go-i2p/onramp).
- **[Source Code](https://github.com/eyedeekay/onramp)**
- **[Source Code](https://github.com/go-i2p/onramp)**
STATUS: This project is maintained. I will respond to issues, pull requests, and feature requests within a few days.
@@ -38,7 +40,7 @@ package main
import (
"log"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {
@@ -64,7 +66,7 @@ package main
import (
"log"
"github.com/eyedeekay/onramp"
"github.com/go-i2p/onramp"
)
func main() {

View File

@@ -4,37 +4,41 @@
package onramp
import (
"github.com/sirupsen/logrus"
"net"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/go-i2p/logger"
"github.com/sirupsen/logrus"
)
var log = logger.GetGoI2PLogger()
//go:generate go run -tags gen ./gen.go
// GetJoinedWD returns the working directory joined with the given path.
func GetJoinedWD(dir string) (string, error) {
wd, err := os.Getwd()
if err != nil {
log.WithError(err).Error("Failed to get working directory")
//log.WithError(err).Error("Failed to get working directory")
return "", err
}
jwd := filepath.Join(wd, dir)
ajwd, err := filepath.Abs(jwd)
if err != nil {
log.WithError(err).WithField("path", jwd).Error("Failed to get absolute path")
//log.WithError(err).WithField("path", jwd).Error("Failed to get absolute path")
return "", err
}
if _, err := os.Stat(ajwd); err != nil {
log.WithField("path", ajwd).Debug("Directory does not exist, creating")
//log.WithField("path", ajwd).Debug("Directory does not exist, creating")
if err := os.MkdirAll(ajwd, 0755); err != nil {
log.WithError(err).WithField("path", ajwd).Error("Failed to create directory")
//log.WithError(err).WithField("path", ajwd).Error("Failed to create directory")
return "", err
}
}
log.WithField("path", ajwd).Debug("Successfully got joined working directory")
//log.WithField("path", ajwd).Debug("Successfully got joined working directory")
return ajwd, nil
}

View File

@@ -7,7 +7,6 @@ import (
"context"
"crypto/tls"
"fmt"
"github.com/sirupsen/logrus"
"net"
"os"
"path/filepath"
@@ -15,6 +14,7 @@ import (
"github.com/go-i2p/i2pkeys"
"github.com/go-i2p/sam3"
"github.com/sirupsen/logrus"
)
// Garlic is a ready-made I2P streaming manager. Once initialized it always
@@ -58,6 +58,19 @@ func (g *Garlic) addrString(addr string) string {
func (g *Garlic) String() string {
var r string
if g.ServiceKeys == nil {
if g.StreamSession != nil {
k := g.StreamSession.Keys()
g.ServiceKeys = &k
}
if g.DatagramSession != nil {
k := g.StreamSession.Keys()
g.ServiceKeys = &k
}
if g.ServiceKeys == nil {
return ""
}
}
switch g.AddrMode {
case DEST_HASH:
r = g.ServiceKeys.Address.DestHash().Hash()
@@ -75,7 +88,7 @@ func (g *Garlic) String() string {
default:
r = g.ServiceKeys.Address.DestHash().Hash()
}
return g.addrString(r) //r //strings.TrimLeft(strings.TrimRight(r, "\n"), "\n") //strings.TrimSpace(r)
return g.addrString(r) // r //strings.TrimLeft(strings.TrimRight(r, "\n"), "\n") //strings.TrimSpace(r)
}
func (g *Garlic) getName() string {
@@ -175,7 +188,7 @@ func (g *Garlic) NewListener(n, addr string) (net.Listener, error) {
log.Debug("Successfully created listener")
return listener, nil
//return g.Listen(n)
// return g.Listen(n)
}
// Listen returns a net.Listener for the Garlic structure's I2P keys.
@@ -194,7 +207,7 @@ func (g *Garlic) Listen(args ...string) (net.Listener, error) {
log.Debug("Successfully created listener")
return listener, nil
//return g.OldListen(args...)
// return g.OldListen(args...)
}
// OldListen returns a net.Listener for the Garlic structure's I2P keys.
@@ -204,7 +217,7 @@ func (g *Garlic) OldListen(args ...string) (net.Listener, error) {
if len(args) > 0 {
protocol := args[0]
log.WithField("protocol", protocol).Debug("Checking protocol type")
//if args[0] == "tcp" || args[0] == "tcp6" || args[0] == "st" || args[0] == "st6" {
// if args[0] == "tcp" || args[0] == "tcp6" || args[0] == "st" || args[0] == "st6" {
if protocol == "tcp" || protocol == "tcp6" || protocol == "st" || protocol == "st6" {
log.Debug("Using TCP stream listener")
return g.ListenStream()
@@ -284,14 +297,13 @@ func (g *Garlic) ListenTLS(args ...string) (net.Listener, error) {
protocol := args[0]
log.WithField("protocol", protocol).Debug("Creating TLS listener for protocol")
//if args[0] == "tcp" || args[0] == "tcp6" || args[0] == "st" || args[0] == "st6" {
// if args[0] == "tcp" || args[0] == "tcp6" || args[0] == "st" || args[0] == "st6" {
if protocol == "tcp" || protocol == "tcp6" || protocol == "st" || protocol == "st6" {
log.Debug("Creating TLS stream listener")
tlsConfig := tlsConfig(cert)
return tls.NewListener(
g.StreamListener,
&tls.Config{
Certificates: []tls.Certificate{cert},
},
tlsConfig,
), nil
//} else if args[0] == "udp" || args[0] == "udp6" || args[0] == "dg" || args[0] == "dg6" {
} else if protocol == "udp" || protocol == "udp6" || protocol == "dg" || protocol == "dg6" {
@@ -317,6 +329,24 @@ func (g *Garlic) ListenTLS(args ...string) (net.Listener, error) {
), nil
}
func tlsConfig(cert tls.Certificate) *tls.Config {
x := &tls.Config{
Certificates: []tls.Certificate{cert},
}
return x
}
// TLSConfig returns the TLS config for the Garlic structure.
// it will return a TLS config even if a service is not currently using TLS.
func (g *Garlic) TLSConfig() (*tls.Config, error) {
cert, err := g.TLSKeys()
if err != nil {
log.WithError(err).Error("Failed to get TLS keys")
return nil, fmt.Errorf("onramp TLSConfig: %v", err)
}
return tlsConfig(cert), nil
}
// Dial returns a net.Conn for the Garlic structure's I2P keys.
func (g *Garlic) Dial(net, addr string) (net.Conn, error) {
log.WithFields(logrus.Fields{
@@ -344,7 +374,7 @@ func (g *Garlic) Dial(net, addr string) (net.Conn, error) {
}
log.Debug("Successfully established connection")
return conn, nil
//return g.StreamSession.Dial(net, addr)
// return g.StreamSession.Dial(net, addr)
}
// DialContext returns a net.Conn for the Garlic structure's I2P keys.
@@ -375,7 +405,7 @@ func (g *Garlic) DialContext(ctx context.Context, net, addr string) (net.Conn, e
log.Debug("Successfully established connection")
return conn, nil
//return g.StreamSession.DialContext(ctx, net, addr)
// return g.StreamSession.DialContext(ctx, net, addr)
}
// Close closes the Garlic structure's sessions and listeners.
@@ -422,7 +452,7 @@ func (g *Garlic) Keys() (*i2pkeys.I2PKeys, error) {
}
func (g *Garlic) DeleteKeys() error {
//return DeleteGarlicKeys(g.getName())
// return DeleteGarlicKeys(g.getName())
log.WithField("name", g.getName()).Debug("Attempting to delete Garlic keys")
err := DeleteGarlicKeys(g.getName())
if err != nil {
@@ -561,7 +591,7 @@ func CloseGarlic(tunName string) {
g, ok := garlics[tunName]
if ok {
log.Debug("Found Garlic connection, closing")
//g.Close()
// g.Close()
err := g.Close()
if err != nil {
log.WithError(err).Error("Error closing Garlic connection")
@@ -621,5 +651,5 @@ func DialGarlic(network, addr string) (net.Conn, error) {
log.Debug("Successfully established Garlic connection")
return conn, nil
//return g.Dial(network, addr)
// return g.Dial(network, addr)
}

View File

@@ -2,10 +2,14 @@ package onramp
import "github.com/go-i2p/sam3"
var OPT_DEFAULTS = sam3.Options_Default
var OPT_WIDE = sam3.Options_Wide
var (
OPT_DEFAULTS = sam3.Options_Default
OPT_WIDE = sam3.Options_Wide
)
var OPT_HUGE = sam3.Options_Humongous
var OPT_LARGE = sam3.Options_Large
var OPT_MEDIUM = sam3.Options_Medium
var OPT_SMALL = sam3.Options_Small
var (
OPT_HUGE = sam3.Options_Humongous
OPT_LARGE = sam3.Options_Large
OPT_MEDIUM = sam3.Options_Medium
OPT_SMALL = sam3.Options_Small
)

View File

@@ -6,7 +6,7 @@ package onramp
import (
"crypto/tls"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"testing"
@@ -52,7 +52,7 @@ func TestBareGarlic(t *testing.T) {
}
defer resp.Body.Close()
fmt.Println(resp.Status)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Error(err)
}

12
go.mod
View File

@@ -1,17 +1,17 @@
module github.com/go-i2p/onramp
go 1.18
go 1.24.2
require (
github.com/cretz/bine v0.2.0
github.com/go-i2p/i2pkeys v0.33.10-0.20241113193422-e10de5e60708
github.com/go-i2p/sam3 v0.33.9
github.com/go-i2p/i2pkeys v0.33.92
github.com/go-i2p/logger v0.0.0-20241123010126-3050657e5d0c
github.com/go-i2p/sam3 v0.33.92
github.com/sirupsen/logrus v1.9.3
)
require (
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.27.0 // indirect
)

23
go.sum
View File

@@ -3,28 +3,25 @@ github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbe
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-i2p/i2pkeys v0.0.0-20241108200332-e4f5ccdff8c4 h1:LRjaRCzg1ieGKZjELlaIg06Fx04RHzQLsWMYp1H6PQ4=
github.com/go-i2p/i2pkeys v0.0.0-20241108200332-e4f5ccdff8c4/go.mod h1:m5TlHjPZrU5KbTd7Lr+I2rljyC6aJ88HdkeMQXV0U0E=
github.com/go-i2p/i2pkeys v0.33.9/go.mod h1:Apt0rKbwylG37GoTAmovuJvB4lu0yFM2sgfIUefbMK8=
github.com/go-i2p/i2pkeys v0.33.10-0.20241113193422-e10de5e60708 h1:Tiy9IBwi21maNpK74yCdHursJJMkyH7w87tX1nXGWzg=
github.com/go-i2p/i2pkeys v0.33.10-0.20241113193422-e10de5e60708/go.mod h1:m5TlHjPZrU5KbTd7Lr+I2rljyC6aJ88HdkeMQXV0U0E=
github.com/go-i2p/sam3 v0.33.9 h1:3a+gunx75DFc6jxloUZTAVJbdP6736VU1dy2i7I9fKA=
github.com/go-i2p/sam3 v0.33.9/go.mod h1:oDuV145l5XWKKafeE4igJHTDpPwA0Yloz9nyKKh92eo=
github.com/go-i2p/i2pkeys v0.33.92 h1:e2vx3vf7tNesaJ8HmAlGPOcfiGM86jzeIGxh27I9J2Y=
github.com/go-i2p/i2pkeys v0.33.92/go.mod h1:BRURQ/twxV0WKjZlFSKki93ivBi+MirZPWudfwTzMpE=
github.com/go-i2p/logger v0.0.0-20241123010126-3050657e5d0c h1:VTiECn3dFEmUlZjto+wOwJ7SSJTHPLyNprQMR5HzIMI=
github.com/go-i2p/logger v0.0.0-20241123010126-3050657e5d0c/go.mod h1:te7Zj3g3oMeIl8uBXAgO62UKmZ6m6kHRNg1Mm+X8Hzk=
github.com/go-i2p/sam3 v0.33.92 h1:TVpi4GH7Yc7nZBiE1QxLjcZfnC4fI/80zxQz1Rk36BA=
github.com/go-i2p/sam3 v0.33.92/go.mod h1:oDuV145l5XWKKafeE4igJHTDpPwA0Yloz9nyKKh92eo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -35,5 +32,5 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

50
log.go
View File

@@ -1,50 +0,0 @@
package onramp
import (
"github.com/sirupsen/logrus"
"io"
"os"
"strings"
"sync"
)
var (
log *logrus.Logger
once sync.Once
)
func InitializeOnrampLogger() {
once.Do(func() {
log = logrus.New()
// We do not want to log by default
log.SetOutput(io.Discard)
log.SetLevel(logrus.PanicLevel)
// Check if DEBUG_I2P is set
if logLevel := os.Getenv("DEBUG_I2P"); logLevel != "" {
log.SetOutput(os.Stdout)
switch strings.ToLower(logLevel) {
case "debug":
log.SetLevel(logrus.DebugLevel)
case "warn":
log.SetLevel(logrus.WarnLevel)
case "error":
log.SetLevel(logrus.ErrorLevel)
default:
log.SetLevel(logrus.DebugLevel)
}
log.WithField("level", log.GetLevel()).Debug("Logging enabled.")
}
})
}
// GetI2PKeysLogger returns the initialized logger
func GetOnrampLogger() *logrus.Logger {
if log == nil {
InitializeOnrampLogger()
}
return log
}
func init() {
GetOnrampLogger()
}

View File

@@ -7,11 +7,12 @@ import (
"context"
"crypto/tls"
"fmt"
"github.com/sirupsen/logrus"
"net"
"os"
"path/filepath"
"github.com/sirupsen/logrus"
"github.com/cretz/bine/tor"
"github.com/cretz/bine/torutil/ed25519"
)
@@ -70,7 +71,7 @@ func (o *Onion) getTor() *tor.Tor {
torp, err = tor.Start(o.getContext(), o.getStartConf())
if err != nil {
log.WithError(err).Error("Failed to start Tor")
panic(err) //return nil instead?
panic(err) // return nil instead?
}
log.Debug("Tor instance started successfully")
}
@@ -78,9 +79,9 @@ func (o *Onion) getTor() *tor.Tor {
}
func (o *Onion) getDialer() *tor.Dialer {
//if o.Dialer == nil {
//var err error
//o.Dialer, err
// if o.Dialer == nil {
// var err error
// o.Dialer, err
log.Debug("Creating new Tor dialer")
dialer, err := o.getTor().Dialer(o.getContext(), o.getDialConf())
if err != nil {
@@ -123,7 +124,7 @@ func (o *Onion) Listen(args ...string) (net.Listener, error) {
log.Debug("Successfully created Onion listener")
return listener, nil
//return o.OldListen(args...)
// return o.OldListen(args...)
}
// OldListen returns a net.Listener which will listen on an onion
@@ -140,7 +141,7 @@ func (o *Onion) OldListen(args ...string) (net.Listener, error) {
log.Debug("Successfully created Tor listener")
return listener, nil
//return o.getTor().Listen(o.getContext(), o.getListenConf())
// return o.getTor().Listen(o.getContext(), o.getListenConf())
}
// ListenTLS returns a net.Listener which will apply TLS encryption
@@ -182,7 +183,7 @@ func (o *Onion) Dial(net, addr string) (net.Conn, error) {
log.Debug("Successfully established Tor connection")
return conn, nil
//return o.getDialer().DialContext(o.getContext(), net, addr)
// return o.getDialer().DialContext(o.getContext(), net, addr)
}
// Close closes the Onion Service and all associated resources.
@@ -197,7 +198,7 @@ func (o *Onion) Close() error {
log.Debug("Successfully closed Onion service")
return nil
//return o.getTor().Close()
// return o.getTor().Close()
}
// Keys returns the keys for the Onion
@@ -212,7 +213,7 @@ func (o *Onion) Keys() (ed25519.KeyPair, error) {
log.Debug("Successfully retrieved Onion keys")
return keys, nil
//return TorKeys(o.getName())
// return TorKeys(o.getName())
}
// DeleteKeys deletes the keys at the given key name in the key store.
@@ -343,7 +344,7 @@ func ListenOnion(network, keys string) (net.Listener, error) {
log.Debug("Successfully created Onion listener")
return listener, nil
//return g.Listen()
// return g.Listen()
}
// DialOnion returns a net.Conn for a onion structure's keys

View File

@@ -6,7 +6,7 @@ package onramp
import (
"crypto/tls"
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"
)
@@ -24,7 +24,7 @@ func TestBareOnion(t *testing.T) {
t.Error(err)
}
log.Println("listener:", listener.Addr().String())
//defer listener.Close()
// defer listener.Close()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", r.URL.Path)
})
@@ -44,7 +44,7 @@ func TestBareOnion(t *testing.T) {
t.Error(err)
}
fmt.Println("Status:", resp.Status)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Error(err)
}

View File

@@ -1,10 +1,11 @@
package onramp
import (
"github.com/sirupsen/logrus"
"io"
"net"
"strings"
"github.com/sirupsen/logrus"
)
type OnrampProxy struct {

3
tls.go
View File

@@ -10,7 +10,6 @@ import (
"encoding/asn1"
"encoding/pem"
"fmt"
"github.com/sirupsen/logrus"
"math/big"
"net"
"os"
@@ -18,6 +17,8 @@ import (
"strings"
"time"
"github.com/sirupsen/logrus"
"github.com/cretz/bine/torutil"
)