client: fix version display and rename client string

- Rename client to "Softether Go Client"
- Fix node info int fields to use LittleEndian32 encoding matching
  the C client's OutRpcNodeInfo (Admin.c:14693)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Git Sagar 2026-06-06 17:15:35 +05:30
parent ed672e7311
commit 3feb93e679

View file

@ -128,6 +128,14 @@ func Connect(cfg Config) (*Session, error) {
return sess, nil
}
// swapLE32 byte-swaps a uint32 to encode it as little-endian within a big-endian Pack int.
// SoftEther's OutRpcNodeInfo wraps node info fields with LittleEndian32() before PackAddInt,
// and InRpcNodeInfo reads them with LittleEndian32(PackGetInt(...)). Our Pack writes big-endian,
// so we pre-swap to match the C client's wire format.
func swapLE32(v uint32) uint32 {
return (v>>24)&0xFF | (v>>8)&0xFF00 | (v<<8)&0xFF0000 | (v<<24)&0xFF000000
}
// buildAuthPack constructs the authentication Pack sent to the server.
// This includes credentials, client version, connection options, node info, and OS info.
// See: https://github.com/SoftEtherVPN/SoftEtherVPN/blob/v5.02.5187/src/Cedar/Protocol.c#L7289
@ -206,8 +214,10 @@ func buildAuthPack(cfg Config, random [sha1Size]byte) *protocol.Pack {
// (case-insensitive), and PackRead returns NULL on AddElement failure.
// p.AddStr("HubName", cfg.Hub)
p.AddData("UniqueId", uniqueID[:16])
p.AddInt("ClientProductVer", clientVer)
p.AddInt("ClientProductBuild", clientBuild)
// Node info ints use LittleEndian32 encoding (see Admin.c:OutRpcNodeInfo).
// The server reads them back with LittleEndian32(PackGetInt(...)).
p.AddInt("ClientProductVer", swapLE32(clientVer))
p.AddInt("ClientProductBuild", swapLE32(clientBuild))
p.AddInt("ServerProductVer", 0)
p.AddInt("ServerProductBuild", 0)
p.AddIP4("ClientIpAddress", 0)