diff options
Diffstat (limited to 'lib/protocol/deviceid.go')
-rw-r--r-- | lib/protocol/deviceid.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/protocol/deviceid.go b/lib/protocol/deviceid.go index 5effb8e38..fee2f6d65 100644 --- a/lib/protocol/deviceid.go +++ b/lib/protocol/deviceid.go @@ -13,10 +13,15 @@ import ( "github.com/syncthing/syncthing/lib/sha256" ) -const DeviceIDLength = 32 +const ( + DeviceIDLength = 32 + ShortIDStringLength = 7 +) -type DeviceID [DeviceIDLength]byte -type ShortID uint64 +type ( + DeviceID [DeviceIDLength]byte + ShortID uint64 +) var ( LocalDeviceID = repeatedDeviceID(0xff) @@ -94,7 +99,7 @@ func (s ShortID) String() string { } var bs [8]byte binary.BigEndian.PutUint64(bs[:], uint64(s)) - return base32.StdEncoding.EncodeToString(bs[:])[:7] + return base32.StdEncoding.EncodeToString(bs[:])[:ShortIDStringLength] } func (n *DeviceID) UnmarshalText(bs []byte) error { |