@@ -30,10 +30,30 @@ func init() {
30
30
31
31
// Locked returns a boolean whether or not Relay is node-locked
32
32
func Locked () bool {
33
- return Fingerprint != "" // decent proxy for node-locked
33
+ return PublicKey != "" && Fingerprint != "" // decent proxy for node-locked
34
34
}
35
35
36
- // LockedAddr returns a boolean whether or not Relay's bind address is locked
36
+ // LockedFingerprint returns a boolean whether or not Relay is locked to machine fingerprint
37
+ func LockedFingerprint () bool {
38
+ return Fingerprint != ""
39
+ }
40
+
41
+ // LockedPlatform returns a boolean whether or not Relay is locked to machine platform
42
+ func LockedPlatform () bool {
43
+ return Platform != ""
44
+ }
45
+
46
+ // LockedHostname returns a boolean whether or not Relay is locked to machine hostname
47
+ func LockedHostname () bool {
48
+ return Hostname != ""
49
+ }
50
+
51
+ // LockedIP returns a boolean whether or not Relay is locked to machine IP address
52
+ func LockedIP () bool {
53
+ return IP != ""
54
+ }
55
+
56
+ // LockedAddr returns a boolean whether or not Relay's bind IP address is locked
37
57
func LockedAddr () bool {
38
58
return Addr != ""
39
59
}
@@ -88,15 +108,15 @@ func Unlock(config Config) (*keygen.MachineFileDataset, error) {
88
108
return nil , fmt .Errorf ("machine file fingerprint mismatch" )
89
109
}
90
110
91
- if Platform != "" {
111
+ if LockedPlatform () {
92
112
platform := runtime .GOOS + "/" + runtime .GOARCH
93
113
94
114
if expected , actual := Platform , platform ; dataset .Machine .Platform != expected || actual != expected {
95
115
return nil , fmt .Errorf ("machine file platform mismatch" )
96
116
}
97
117
}
98
118
99
- if Hostname != "" {
119
+ if LockedHostname () {
100
120
hostname , err := os .Hostname ()
101
121
if err != nil {
102
122
return nil , fmt .Errorf ("machine could not determine hostname: %w" , err )
@@ -107,7 +127,7 @@ func Unlock(config Config) (*keygen.MachineFileDataset, error) {
107
127
}
108
128
}
109
129
110
- if IP != "" {
130
+ if LockedIP () {
111
131
ip , err := getPrivateIP ()
112
132
if err != nil {
113
133
return nil , fmt .Errorf ("machine could not determine ip: %w" , err )
0 commit comments