]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
vici: Create default TCP socket on Windows in Python bindings
authorTobias Brunner <tobias@strongswan.org>
Thu, 20 Apr 2023 14:26:52 +0000 (16:26 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 1 May 2023 08:19:29 +0000 (10:19 +0200)
This uses the same value as VICI_DEFAULT_URI.

References strongswan/strongswan#1655

src/libcharon/plugins/vici/python/vici/session.py

index f45ff952e5ad4f5960adc198327af8fa4b75c46b..a031d12deaf34f1e7a005da939f407b062cee29e 100644 (file)
@@ -1,4 +1,5 @@
 import socket
+import platform
 
 from .exception import SessionException, CommandException, EventUnknownException
 from .protocol import Transport, Packet, Message, RECV_TIMEOUT_DEFAULT
@@ -26,8 +27,12 @@ class Session(CommandWrappers, object):
         :type sock: socket.socket
         """
         if sock is None:
-            sock = socket.socket(socket.AF_UNIX)
-            sock.connect("/var/run/charon.vici")
+            if platform.system() == "Windows":
+                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+                sock.connect('127.0.0.1', 4502)
+            else:
+                sock = socket.socket(socket.AF_UNIX)
+                sock.connect("/var/run/charon.vici")
         self.transport = Transport(sock)
 
     def _communicate(self, packet):