mirror of
				https://github.com/nadoo/glider.git
				synced 2025-10-31 22:05:51 +08:00 
			
		
		
		
	fixed a bug in ha mode
This commit is contained in:
		
							parent
							
								
									c79a9ee36d
								
							
						
					
					
						commit
						1f13a8d1e8
					
				
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							| @ -10,7 +10,7 @@ import ( | |||||||
| 	"syscall" | 	"syscall" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const version = "0.1" | const version = "0.1.1" | ||||||
| 
 | 
 | ||||||
| var config struct { | var config struct { | ||||||
| 	Verbose       bool | 	Verbose       bool | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								mixed.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								mixed.go
									
									
									
									
									
								
							| @ -25,7 +25,7 @@ type mixedproxy struct { | |||||||
| 	ss     Proxy | 	ss     Proxy | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // MixedProxy returns a http mixed proxy.
 | // MixedProxy returns a mixed proxy.
 | ||||||
| func MixedProxy(network, addr, user, pass string, upProxy Proxy) (Proxy, error) { | func MixedProxy(network, addr, user, pass string, upProxy Proxy) (Proxy, error) { | ||||||
| 	p := &mixedproxy{ | 	p := &mixedproxy{ | ||||||
| 		Proxy: upProxy, | 		Proxy: upProxy, | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								proxy.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								proxy.go
									
									
									
									
									
								
							| @ -138,15 +138,17 @@ func check(p Proxy, target string, duration int) { | |||||||
| 		} | 		} | ||||||
| 		firstTime = false | 		firstTime = false | ||||||
| 
 | 
 | ||||||
|  | 		startTime := time.Now() | ||||||
| 		c, err := p.Dial("tcp", target) | 		c, err := p.Dial("tcp", target) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			logf("proxy %s check error: %s, set to disabled.", p.Addr(), err) | 			logf("proxy-check %s -> %s, error: %s, set to disabled.", p.Addr(), config.CheckSite, err) | ||||||
| 			p.SetEnable(false) | 			p.SetEnable(false) | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|  | 		dialTime := time.Since(startTime) | ||||||
| 		c.Close() | 		c.Close() | ||||||
| 
 | 
 | ||||||
| 		p.SetEnable(true) | 		p.SetEnable(true) | ||||||
| 		logf("proxy %s check ok.", p.Addr()) | 		logf("proxy-check: %s -> %s, connect time: %d", p.Addr(), config.CheckSite, dialTime) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -74,7 +74,7 @@ type haproxy struct { | |||||||
| 
 | 
 | ||||||
| // newHAProxy .
 | // newHAProxy .
 | ||||||
| func newHAProxy(addr string, forwarders []Proxy) Proxy { | func newHAProxy(addr string, forwarders []Proxy) Proxy { | ||||||
| 	return newStrategyProxy(addr, forwarders) | 	return &haproxy{Proxy: newStrategyProxy(addr, forwarders)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (p *haproxy) GetProxy() Proxy { | func (p *haproxy) GetProxy() Proxy { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 nadoo
						nadoo