-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e018ae
commit 03cad95
Showing
6 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package modernforge | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// Token is the token used in the modern forge handshake. | ||
const Token = "FORGE" | ||
|
||
// ModernToken aligns the acquisition logic with the internal code of Forge. | ||
func ModernToken(hostName string) string { | ||
natVersion := 0 | ||
idx := strings.Index(hostName, "\000") | ||
if idx != -1 { | ||
for _, pt := range strings.Split(hostName, "\000") { | ||
if strings.HasPrefix(pt, Token) { | ||
if len(pt) > len(Token) { | ||
natVersion, _ = strconv.Atoi(pt[len(Token):]) | ||
} | ||
} | ||
} | ||
} | ||
if natVersion == 0 { | ||
return "\000" + Token | ||
} | ||
return "\000" + Token + strconv.Itoa(natVersion) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters