Use pseudo-random high port for UPnP mapping

This commit is contained in:
Jakob Borg
2014-04-18 14:09:54 +02:00
parent a08cba9c85
commit 292a50de04
2 changed files with 16 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/base32"
"encoding/binary"
"encoding/pem"
"math/big"
"os"
@@ -32,6 +33,13 @@ func certID(bs []byte) string {
return strings.Trim(base32.StdEncoding.EncodeToString(id), "=")
}
func certSeed(bs []byte) int64 {
hf := sha256.New()
hf.Write(bs)
id := hf.Sum(nil)
return int64(binary.BigEndian.Uint64(id))
}
func newCertificate(dir string) {
infoln("Generating RSA certificate and key...")