mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Prevent duplicate domains
Now checks to make sure a domain isn't already used by a previous tunnel. This prevents accidental silent modifications to tunnels and also fixes a bug where multiple entries were being made in the authorized_keys file.
This commit is contained in:
parent
12ec55cf37
commit
b9d07f9663
@ -76,11 +76,16 @@ func (m *TunnelManager) RequestCreateTunnel(tunReq Tunnel) (Tunnel, error) {
|
||||
if err != nil {
|
||||
return Tunnel{}, err
|
||||
}
|
||||
} else {
|
||||
for _, tun := range m.db.GetTunnels() {
|
||||
if tunReq.TunnelPort == tun.TunnelPort {
|
||||
return Tunnel{}, errors.New("Tunnel port already in use")
|
||||
}
|
||||
}
|
||||
|
||||
for _, tun := range m.db.GetTunnels() {
|
||||
fmt.Println(tunReq.Domain, tun.Domain)
|
||||
if tunReq.Domain == tun.Domain {
|
||||
return Tunnel{}, errors.New("Tunnel domain already in use")
|
||||
}
|
||||
|
||||
if tunReq.TunnelPort == tun.TunnelPort {
|
||||
return Tunnel{}, errors.New("Tunnel port already in use")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user