mirror of
https://github.com/go-i2p/go-i2ptunnel.git
synced 2025-12-20 15:15:52 -05:00
IRC client
This commit is contained in:
@@ -5,10 +5,3 @@
|
||||
./lib/http/client/httpclient.go-97-func (h *HTTPClient) Stop() error {
|
||||
./lib/http/client/httpclient.go:98: panic("unimplemented")
|
||||
./lib/http/client/httpclient.go-99-}
|
||||
./lib/irc/client/client.go-80-func (i *IRCClient) Start() error {
|
||||
./lib/irc/client/client.go:81: panic("unimplemented")
|
||||
./lib/irc/client/client.go-82-}
|
||||
--
|
||||
./lib/irc/client/client.go-90-func (i *IRCClient) Stop() error {
|
||||
./lib/irc/client/client.go:91: panic("unimplemented")
|
||||
./lib/irc/client/client.go-92-}
|
||||
|
||||
@@ -13,10 +13,13 @@ The IRC Client implements a SOCKS-compatible proxy that enables local IRC client
|
||||
**/
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
ircinspector "github.com/go-i2p/go-connfilter/irc"
|
||||
"github.com/go-i2p/go-forward/config"
|
||||
"github.com/go-i2p/go-forward/stream"
|
||||
i2pconv "github.com/go-i2p/go-i2ptunnel-config/lib"
|
||||
i2ptunnel "github.com/go-i2p/go-i2ptunnel/lib/core"
|
||||
"github.com/go-i2p/i2pkeys"
|
||||
@@ -78,7 +81,35 @@ func (i *IRCClient) Options() map[string]string {
|
||||
|
||||
// Start the tunnel
|
||||
func (i *IRCClient) Start() error {
|
||||
panic("unimplemented")
|
||||
i2pConn, err := i.Garlic.Dial("tcp", i.Target())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.I2PTunnelStatus = i2ptunnel.I2PTunnelStatusStarting
|
||||
defer i2pConn.Close()
|
||||
defer i.Stop()
|
||||
listener, err := net.Listen("tcp", net.JoinHostPort(i.Interface, strconv.Itoa(i.Port)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer listener.Close()
|
||||
filteredListener := ircinspector.New(listener, i.Config)
|
||||
defer filteredListener.Close()
|
||||
i.I2PTunnelStatus = i2ptunnel.I2PTunnelStatusRunning
|
||||
for {
|
||||
select {
|
||||
case <-i.done:
|
||||
return nil
|
||||
default:
|
||||
con, err := filteredListener.Accept()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
defer con.Close()
|
||||
ctx := context.Background()
|
||||
stream.Forward(ctx, con, i2pConn, config.DefaultConfig())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the tunnel's status
|
||||
@@ -88,7 +119,10 @@ func (i *IRCClient) Status() i2ptunnel.I2PTunnelStatus {
|
||||
|
||||
// Stop the tunnel
|
||||
func (i *IRCClient) Stop() error {
|
||||
panic("unimplemented")
|
||||
close(i.done)
|
||||
// Cleanup resources
|
||||
i.I2PTunnelStatus = i2ptunnel.I2PTunnelStatusStopped
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get the tunnel's I2P target. Nil in the case of one-to-many clients like SOCKS5 and HTTP
|
||||
|
||||
Reference in New Issue
Block a user