Fix TlsTcpClient. Update console scene.

This commit is contained in:
2022-10-26 00:05:03 +08:00
parent 5db567e42c
commit 6b6b7d9a48
2 changed files with 16 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ using System.Collections;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
namespace Cryville.Common.Network {
public class TlsTcpClient {
@@ -16,7 +17,7 @@ namespace Cryville.Common.Network {
public TlsTcpClient(string hostname, int port) {
_tcpClient = new TcpClient(hostname, port);
_protocol = new TlsClientProtocol(_tcpClient.GetStream());
_tlsClient = new InternalTlsClient(new BcTlsCrypto(new SecureRandom()));
_tlsClient = new InternalTlsClient(hostname, new BcTlsCrypto(new SecureRandom()));
}
public void Connect() {
@@ -29,7 +30,11 @@ namespace Cryville.Common.Network {
}
private class InternalTlsClient : DefaultTlsClient {
public InternalTlsClient(TlsCrypto crypto) : base(crypto) { }
string _host;
public InternalTlsClient(string host, TlsCrypto crypto) : base(crypto) {
_host = host;
}
protected override ProtocolVersion[] GetSupportedVersions() {
return ProtocolVersion.TLSv13.DownTo(ProtocolVersion.TLSv12);
@@ -37,8 +42,7 @@ namespace Cryville.Common.Network {
protected override IList GetProtocolNames() {
IList list = new ArrayList {
ProtocolName.Http_1_1,
ProtocolName.Http_2_Tls
ProtocolName.Http_1_1
};
return list;
}
@@ -62,6 +66,10 @@ namespace Cryville.Common.Network {
return result;
}
protected override IList GetSniServerNames() {
return new ArrayList { new ServerName(0, Encoding.ASCII.GetBytes(_host)) };
}
public override TlsAuthentication GetAuthentication() {
return new NullTlsAuthentication();
}

View File

@@ -26,6 +26,10 @@ namespace Cryville.Crtr {
worker.Activate();
}
void OnApplicationQuit() {
Game.Shutdown();
}
public void Submit() {
worker.Issue(InputBox.text);
}