我正在使用下面的随需连接规则在Swift中创建VPN连接:
let config = NEVPNProtocolIPSec()
config.serverAddress = ""
config.username = ""
config.passwordReference = ""
config.authenticationMethod = .sharedSecret
config.sharedSecretReference = ""
config.useExtendedAuthentication = true
config.disconnectOnSleep = true
let connectRule = NEOnDemandRuleConnect()
connectRule.interfaceTypeMatch = .any
vpnManager.onDemandRules = [connectRule]
vpnManager.protocolConfiguration = config
vpnManager.localizedDescription = ""
vpnManager.isOnDemandEnabled = true
vpnManager.isEnabled = true
Run Code Online (Sandbox Code Playgroud)
这种连接工作正常.如果我使用WiFi,它会在断开WiFi连接后重新连接,但反之亦然.如果我正在使用蜂窝连接并尝试激活WiFi,则手机将无法连接至WiFi,直到我手动断开其与VPN的连接.我相信一个活跃的VPN连接阻止从4G切换到WiFi.
我该如何解决这个问题?
在新的MSYS2实例上安装 mingw 时,我遇到了 gcc not found 的问题:
$ g++
bash: g++: command not found
Run Code Online (Sandbox Code Playgroud)
在相对干净的 Windows 10 安装上全新安装 MSYS2:
pacman -Syu
pacman -Su
pacman -S make
pacman -S mingw-w64-x86_64-gcc
Run Code Online (Sandbox Code Playgroud)
看来GCC已经成功安装到该目录了/mingw64/bin
然而我的道路包括
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:
Run Code Online (Sandbox Code Playgroud)
因此找不到 gcc。
我尝试添加/mingw64/bin
,$PATH
但这似乎是对潜在问题的临时解决。
我的具体问题是,是否有任何原因说明为什么 mingw 未安装到目录中/usr/bin/
或安装未将其自身添加到路径中,或者有任何简单的原因导致此问题。
提前致谢!
我有一个集合,其中包含我定义的对象__eq__
和__hash__
函数。
我希望能够检查具有相同哈希值的对象是否在集合中,以及它是否在集合中以从集合中返回对象,因为我需要对该对象的引用。
class SetObject():
def __init__(
self,
a: int,
b: int,
c: int
):
self.a = a
self.b = b
self.c = c
def __repr__(self):
return f"SetObject ({self.a} {self.b} {self.c}) (id: {id(self)}"
def __eq__(self, other):
return isinstance(other, SetObject) \
and self.__hash__() == other.__hash__()
def __hash__(self):
# Hash only depends on a, b
return hash(
(self.a,self.b)
)
x = SetObject(1,2,3)
y = SetObject(4,5,6)
object_set = set([x,y])
print(f"{object_set=}")
z = SetObject(1,2,7)
print(f"{z=}")
if z in object_set:
print("Is in …
Run Code Online (Sandbox Code Playgroud)