mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Merge pull request #106 from boringproxy/fix-authorized-keys
Fix authorized keys
This commit is contained in:
commit
82241ecc0c
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +202,16 @@ func (m *TunnelManager) addToAuthorizedKeys(domain string, port int, allowExtern
|
||||
|
||||
newAk := fmt.Sprintf("%s%s %s %s\n", akStr, options, pubKey, tunnelId)
|
||||
|
||||
// Clear the file
|
||||
err = akFile.Truncate(0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = akFile.Seek(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, err = akFile.Write([]byte(newAk))
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
Loading…
Reference in New Issue
Block a user