Make connection using specific ip
Can we bind specifc ip to irc connection?
Not in the current code. After this line: https://github.com/thoj/go-ircevent/blob/73e444401d645f686b4aa9adcab88fa78cf85a4f/irc.go#L465 Add dialer.LocalAddress := "192.168.0.2"
Pr Welcome.
Hi again, im getting an error: dialer.LocalAddress undefined (type proxy.Dialer has no field or method LocalAddress)
the code is:
dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout})
dialer.LocalAddress = "127.0.0.1"
irc.socket, err = dialer.Dial("tcp", irc.Server)
dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout, LocalAddress: "127.0.0.1"})
irc.socket, err = dialer.Dial("tcp", irc.Server)
Sorry but also error irc.go:466:73: unknown field 'LocalAddress' in struct literal of type net.Dialer
try LocalAddr
If that doesn't work I don't know. Check the go documentation.
Hi i manage to get it work with code: (all changes You can see on my GitHub (In fork)
dialer := proxy.FromEnvironmentUsing(&net.Dialer{ LocalAddr: &net.TCPAddr{
IP: net.ParseIP(irc.myhost),
Port: 0,
},Timeout: irc.Timeout})
//where myhost is passed here:
func IRC(nick, user string, myhost string) *Connection {
// catch invalid values