forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -25,12 +25,15 @@ package python.net;
|
||||
import python.lib.Ssl;
|
||||
import python.lib.ssl.Purpose;
|
||||
import python.lib.socket.Socket as PSocket;
|
||||
import python.lib.Socket in PSocketModule;
|
||||
import sys.net.Host;
|
||||
|
||||
class SslSocket extends sys.net.Socket {
|
||||
var hostName:String;
|
||||
var _timeout:Null<Float> = null;
|
||||
var _blocking:Null<Bool> = null;
|
||||
var _fastSend:Null<Bool> = null;
|
||||
|
||||
override function __initSocket():Void {
|
||||
function wrapSocketWithSslContext(hostName:String):Void {
|
||||
#if (python_version >= 3.4)
|
||||
var context = Ssl.create_default_context(Purpose.SERVER_AUTH);
|
||||
#else
|
||||
@ -43,16 +46,42 @@ class SslSocket extends sys.net.Socket {
|
||||
context.options |= Ssl.OP_NO_COMPRESSION;
|
||||
#end
|
||||
context.options |= Ssl.OP_NO_TLSv1 #if (python_version >= 3.4) | Ssl.OP_NO_TLSv1_1 #end; // python 3.4 | Ssl.OP_NO_TLSv1_1;
|
||||
__s = new PSocket();
|
||||
__s = context.wrap_socket(__s, false, true, true, this.hostName);
|
||||
__s = context.wrap_socket(__s, false, true, true, hostName);
|
||||
if (_timeout != null) {
|
||||
super.setTimeout(_timeout);
|
||||
}
|
||||
|
||||
if (_blocking != null) {
|
||||
super.setBlocking(_blocking);
|
||||
}
|
||||
|
||||
if (_fastSend != null) {
|
||||
super.setFastSend(_fastSend);
|
||||
}
|
||||
__rebuildIoStreams();
|
||||
}
|
||||
|
||||
public override function connect(host:Host, port:Int):Void {
|
||||
this.hostName = host.host;
|
||||
wrapSocketWithSslContext(host.host);
|
||||
super.connect(host, port);
|
||||
}
|
||||
|
||||
public override function bind(host:Host, port:Int):Void {
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
|
||||
public override function setTimeout(timeout:Float):Void {
|
||||
_timeout = timeout;
|
||||
super.setTimeout(_timeout);
|
||||
}
|
||||
|
||||
public override function setBlocking(b:Bool):Void {
|
||||
_blocking = b;
|
||||
super.setBlocking(_blocking);
|
||||
}
|
||||
|
||||
public override function setFastSend(b:Bool):Void {
|
||||
_fastSend = b;
|
||||
super.setFastSend(_fastSend);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user