the uri should already be valid maybe
This commit is contained in:
parent
2eaeb6c3fd
commit
3e507c41a5
16
daemons.go
16
daemons.go
@ -3,11 +3,9 @@ package Prox5
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func (s *Swamp) svcUp() {
|
func (s *Swamp) svcUp() {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.runningdaemons++
|
s.runningdaemons++
|
||||||
@ -37,28 +35,20 @@ func (sm swampMap) add(sock string) (*Proxy, bool) {
|
|||||||
sm.mu.Lock()
|
sm.mu.Lock()
|
||||||
defer sm.mu.Unlock()
|
defer sm.mu.Unlock()
|
||||||
|
|
||||||
var auth = &proxyAuth{}
|
|
||||||
|
|
||||||
if strings.Contains(sock, "@") {
|
|
||||||
split := strings.Split(sock, "@")
|
|
||||||
sock = split[1]
|
|
||||||
authsplit := strings.Split(split[0], ":")
|
|
||||||
auth.username = authsplit[0]
|
|
||||||
auth.password = authsplit[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
if sm.exists(sock) {
|
if sm.exists(sock) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &Proxy{
|
p := &Proxy{
|
||||||
Endpoint: sock,
|
Endpoint: sock,
|
||||||
lock: stateUnlocked,
|
lock: stateUnlocked,
|
||||||
parent: sm.parent,
|
parent: sm.parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
p.timesValidated.Store(0)
|
p.timesValidated.Store(0)
|
||||||
p.timesBad.Store(0)
|
p.timesBad.Store(0)
|
||||||
sm.plot[sock] = p
|
sm.plot[sock] = p
|
||||||
return p, true
|
return sm.plot[sock], true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm swampMap) exists(sock string) bool {
|
func (sm swampMap) exists(sock string) bool {
|
||||||
|
7
defs.go
7
defs.go
@ -154,11 +154,6 @@ const (
|
|||||||
stateLocked
|
stateLocked
|
||||||
)
|
)
|
||||||
|
|
||||||
type proxyAuth struct {
|
|
||||||
username string
|
|
||||||
password string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Proxy represents an individual proxy
|
// Proxy represents an individual proxy
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
// Endpoint is the address:port of the proxy that we connect to
|
// Endpoint is the address:port of the proxy that we connect to
|
||||||
@ -174,8 +169,6 @@ type Proxy struct {
|
|||||||
// timesBad is the amount of times the proxy has been marked as bad.
|
// timesBad is the amount of times the proxy has been marked as bad.
|
||||||
timesBad atomic.Value
|
timesBad atomic.Value
|
||||||
|
|
||||||
auth *proxyAuth
|
|
||||||
|
|
||||||
parent *Swamp
|
parent *Swamp
|
||||||
lock uint32
|
lock uint32
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user