mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Clear authorized_keys before writing
Was writing both the old content of authorized_keys and the new tunnel every time a tunnel was created. This essentially made the file double in size for every new tunnel added.
This commit is contained in:
parent
e4b6598274
commit
12ec55cf37
@ -197,6 +197,16 @@ func (m *TunnelManager) addToAuthorizedKeys(domain string, port int, allowExtern
|
|||||||
|
|
||||||
newAk := fmt.Sprintf("%s%s %s %s\n", akStr, options, pubKey, tunnelId)
|
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))
|
_, err = akFile.Write([]byte(newAk))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
Reference in New Issue
Block a user