mirror of
				https://github.com/fluffle/goirc
				synced 2025-11-03 19:48:04 +00:00 
			
		
		
		
	Merge pull request #52 from Krayons/master
Added timeout to deal with connecting to slow and unreliable IRCservers
This commit is contained in:
		
						commit
						57eecccd1b
					
				
					 1 changed files with 7 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -83,6 +83,9 @@ type Config struct {
 | 
			
		|||
	// Split PRIVMSGs, NOTICEs and CTCPs longer than
 | 
			
		||||
	// SplitLen characters over multiple lines.
 | 
			
		||||
	SplitLen int
 | 
			
		||||
 | 
			
		||||
	// Timeout, The amount of time in seconds until a timeout is triggered.
 | 
			
		||||
	Timeout time.Duration
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewConfig(nick string, args ...string) *Config {
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +95,7 @@ func NewConfig(nick string, args ...string) *Config {
 | 
			
		|||
		NewNick:  func(s string) string { return s + "_" },
 | 
			
		||||
		Recover:  (*Conn).LogPanic, // in dispatch.go
 | 
			
		||||
		SplitLen: 450,
 | 
			
		||||
		Timeout:  60 * time.Second,
 | 
			
		||||
	}
 | 
			
		||||
	cfg.Me.Ident = "goirc"
 | 
			
		||||
	if len(args) > 0 && args[0] != "" {
 | 
			
		||||
| 
						 | 
				
			
			@ -124,6 +128,7 @@ func Client(cfg *Config) *Conn {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	dialer := new(net.Dialer)
 | 
			
		||||
	dialer.Timeout = cfg.Timeout
 | 
			
		||||
	if cfg.LocalAddr != "" {
 | 
			
		||||
		if !hasPort(cfg.LocalAddr) {
 | 
			
		||||
			cfg.LocalAddr += ":0"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue