aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2015-12-08 17:13:59 +0100
committerMartin Willi <martin@strongswan.org>2017-02-13 15:04:44 +0100
commit22f08609f1b6aabdc1177e0570c943842478de72 (patch)
tree36a38a8f2e5e9ad299ea3683a52ec140ed195f2a
parent0394bbf58c9ab57e59d1c44c06955f25b7f16f17 (diff)
downloadstrongswan-22f08609f1b6aabdc1177e0570c943842478de72.tar.bz2
strongswan-22f08609f1b6aabdc1177e0570c943842478de72.tar.xz
vici: Explicitly set the Python encoding type
When using vici over RPyC and its (awesome) splitbrain, encoding and decoding strings fails in vici, most likely because of the Monkey-Patch magic splitbrain uses. When specifying the implicit UTF-8 as encoding scheme explicitly, Python uses the correct method to encode/decode the string, making vici useable in splitbrain contexts.
-rw-r--r--src/libcharon/plugins/vici/python/vici/protocol.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcharon/plugins/vici/python/vici/protocol.py b/src/libcharon/plugins/vici/python/vici/protocol.py
index 880d3343c..919231d43 100644
--- a/src/libcharon/plugins/vici/python/vici/protocol.py
+++ b/src/libcharon/plugins/vici/python/vici/protocol.py
@@ -62,7 +62,7 @@ class Packet(object):
@classmethod
def _named_request(cls, request_type, request, message=None):
- request = request.encode()
+ requestdata = request.encode("UTF-8")
payload = struct.pack("!BB", request_type, len(request)) + request
if message is not None:
return payload + message
@@ -105,12 +105,12 @@ class Message(object):
@classmethod
def serialize(cls, message):
def encode_named_type(marker, name):
- name = name.encode()
+ name = name.encode("UTF-8")
return struct.pack("!BB", marker, len(name)) + name
def encode_blob(value):
if not isinstance(value, bytes):
- value = str(value).encode()
+ value = str(value).encode("UTF-8")
return struct.pack("!H", len(value)) + value
def serialize_list(lst):
@@ -147,7 +147,7 @@ class Message(object):
def deserialize(cls, stream):
def decode_named_type(stream):
length, = struct.unpack("!B", stream.read(1))
- return stream.read(length).decode()
+ return stream.read(length).decode("UTF-8")
def decode_blob(stream):
length, = struct.unpack("!H", stream.read(2))