From d36db4f344cda5a7c1d93a82cac778a9869be19e Mon Sep 17 00:00:00 2001 From: Rod Hynes Date: Mon, 16 Dec 2024 14:56:54 -0500 Subject: [PATCH] Add missing network type cases - WIRED was reported as UNKNOWN --- psiphon/common/inproxy/api.go | 6 ++++++ psiphon/inproxy.go | 4 ++++ psiphon/net.go | 3 +++ psiphon/utils.go | 9 ++++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/psiphon/common/inproxy/api.go b/psiphon/common/inproxy/api.go index bbdd3151d..0f9059f7f 100644 --- a/psiphon/common/inproxy/api.go +++ b/psiphon/common/inproxy/api.go @@ -137,6 +137,8 @@ const ( NetworkTypeUnknown NetworkType = iota NetworkTypeWiFi NetworkTypeMobile + NetworkTypeWired + NetworkTypeVPN ) // NetworkProtocol is an Internet protocol, such as TCP or UDP. This enum is @@ -453,6 +455,10 @@ func GetNetworkType(packedBaseParams protocol.PackedAPIParameters) NetworkType { return NetworkTypeWiFi case "MOBILE": return NetworkTypeMobile + case "WIRED": + return NetworkTypeWired + case "VPN": + return NetworkTypeVPN } return NetworkTypeUnknown } diff --git a/psiphon/inproxy.go b/psiphon/inproxy.go index 017bbc7c8..b2dd264c0 100644 --- a/psiphon/inproxy.go +++ b/psiphon/inproxy.go @@ -2501,6 +2501,10 @@ func getInproxyNetworkType(networkType string) inproxy.NetworkType { return inproxy.NetworkTypeWiFi case "MOBILE": return inproxy.NetworkTypeMobile + case "WIRED": + return inproxy.NetworkTypeWired + case "VPN": + return inproxy.NetworkTypeVPN } return inproxy.NetworkTypeUnknown diff --git a/psiphon/net.go b/psiphon/net.go index d7d590936..933eef333 100644 --- a/psiphon/net.go +++ b/psiphon/net.go @@ -179,6 +179,9 @@ type HasIPv6RouteGetter interface { // - "WIRED" for a wired network // - "VPN" for a VPN network // - "UNKNOWN" for when the network type cannot be determined +// +// Note that the functions psiphon.GetNetworkType, psiphon.getInproxyNetworkType, +// and inproxy.GetNetworkType must all be updated when new network types are added. type NetworkIDGetter interface { GetNetworkID() string } diff --git a/psiphon/utils.go b/psiphon/utils.go index b45635abe..3af55bafe 100755 --- a/psiphon/utils.go +++ b/psiphon/utils.go @@ -288,14 +288,17 @@ func GetNetworkType(networkID string) string { // check for and use the common network type prefixes currently used in // NetworkIDGetter implementations. - if strings.HasPrefix(networkID, "VPN") { - return "VPN" - } if strings.HasPrefix(networkID, "WIFI") { return "WIFI" } if strings.HasPrefix(networkID, "MOBILE") { return "MOBILE" } + if strings.HasPrefix(networkID, "WIRED") { + return "WIRED" + } + if strings.HasPrefix(networkID, "VPN") { + return "VPN" + } return "UNKNOWN" }