mirror of
https://github.com/go-i2p/go-i2ptunnel.git
synced 2025-07-12 23:48:37 -04:00
remove inaccurate readme stuff
This commit is contained in:
40
README.md
40
README.md
@ -24,46 +24,6 @@ A Go implementation of I2P tunneling services with support for TCP, HTTP, UDP, a
|
||||
go get github.com/go-i2p/go-i2ptunnel
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### TCP Server Example
|
||||
```go
|
||||
import "github.com/go-i2p/go-i2ptunnel/lib/tcp/server"
|
||||
|
||||
tunnel := tcpserver.NewTCPServer(map[string]string{
|
||||
"name": "my-service",
|
||||
"port": "8080",
|
||||
})
|
||||
|
||||
if err := tunnel.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
### HTTP Proxy Example
|
||||
```go
|
||||
import "github.com/go-i2p/go-i2ptunnel/lib/http/client"
|
||||
|
||||
proxy := httpclient.NewHTTPProxy(map[string]string{
|
||||
"name": "http-proxy",
|
||||
"port": "8118",
|
||||
})
|
||||
|
||||
if err := proxy.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Each tunnel type supports these common options:
|
||||
- `name` - Tunnel identifier
|
||||
- `type` - Tunnel type (server/client)
|
||||
- `port` - Local port to bind
|
||||
- `host` - Local host to bind (default: 127.0.0.1)
|
||||
- `keys` - Path to key file
|
||||
- `destination` - Target I2P address (clients only)
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Check our [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"github.com/go-i2p/onramp"
|
||||
)
|
||||
|
||||
// NewTCPServer creates a new TCP Server tunnel with the given configuration
|
||||
func NewTCPServer(config i2pconv.TunnelConfig, samAddr string) (*TCPClient, error) {
|
||||
// NewTCPClient creates a new TCP Client tunnel with the given configuration
|
||||
func NewTCPClient(config i2pconv.TunnelConfig, samAddr string) (*TCPClient, error) {
|
||||
keys, options, err := config.SAMTunnel()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -19,8 +19,10 @@ func NewTCPServer(config i2pconv.TunnelConfig, samAddr string) (*TCPClient, erro
|
||||
return nil, err
|
||||
}
|
||||
garlic.ServiceKeys = keys
|
||||
// addr := config.
|
||||
return &TCPClient{
|
||||
TunnelConfig: config,
|
||||
Garlic: garlic,
|
||||
I2PAddr: addr,
|
||||
}, nil
|
||||
}
|
||||
|
@ -71,7 +71,8 @@ func (t *TCPClient) Options() map[string]string {
|
||||
|
||||
// Start implements i2ptunnel.I2PTunnel.
|
||||
func (t *TCPClient) Start() error {
|
||||
panic("unimplemented")
|
||||
go func() {
|
||||
}()
|
||||
}
|
||||
|
||||
// Status implements i2ptunnel.I2PTunnel.
|
||||
|
@ -1,6 +1,7 @@
|
||||
package tcpserver
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
i2pconv "github.com/go-i2p/go-i2ptunnel-config/lib"
|
||||
@ -19,8 +20,15 @@ func NewTCPServer(config i2pconv.TunnelConfig, samAddr string) (*TCPServer, erro
|
||||
return nil, err
|
||||
}
|
||||
garlic.ServiceKeys = keys
|
||||
localPort, _ := strconv.Atoi(config.Port)
|
||||
localAddr := net.JoinHostPort(config.Interface, localPort)
|
||||
addr, err := net.ResolveTCPAddr("tcp", localAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &TCPServer{
|
||||
TunnelConfig: config,
|
||||
Garlic: garlic,
|
||||
Addr: addr,
|
||||
}, nil
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ var implementTCPServer i2ptunnel.I2PTunnel = &TCPServer{}
|
||||
type TCPServer struct {
|
||||
// I2P Connection to listen to the I2P network
|
||||
*onramp.Garlic
|
||||
// TCP Connection to the local service
|
||||
net.Conn
|
||||
// The I2P Tunnel config itself
|
||||
i2pconv.TunnelConfig
|
||||
// The local TCP service address
|
||||
@ -63,7 +61,18 @@ func (t *TCPServer) Options() map[string]string {
|
||||
|
||||
// Start implements i2ptunnel.I2PTunnel.
|
||||
func (t *TCPServer) Start() error {
|
||||
panic("unimplemented")
|
||||
i2pListener, err := t.Garlic.Listen()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer i2pListener.Close()
|
||||
for {
|
||||
con, err := i2pListener.Accept()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Status implements i2ptunnel.I2PTunnel.
|
||||
|
Reference in New Issue
Block a user