Skip to content

Commit

Permalink
Merge pull request #1 from youngmonkeys/dev
Browse files Browse the repository at this point in the history
Dev SSL
  • Loading branch information
tvd12 authored Jul 18, 2021
2 parents 541b1a4 + c280fa8 commit bcead70
Show file tree
Hide file tree
Showing 32 changed files with 835 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
import com.tvd12.ezyfoxerver.client.proxy.EzyConnectMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyCreateClientMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyDisconnectMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyGenerateKeyPairMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyLogMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyMethodProxy;
import com.tvd12.ezyfoxerver.client.proxy.EzyReconnectMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyRsaDecryptMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzySendMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzySetSessionKeyMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzySetStatusMethod;
import com.tvd12.ezyfoxerver.client.proxy.EzyStartPingScheduleMethod;
import com.tvd12.ezyfoxserver.client.socket.EzyMainEventsLoop;
Expand Down Expand Up @@ -92,6 +96,10 @@ private void addDefaultMethods() {
addMethod(new EzySendMethod());
addMethod(new EzySetStatusMethod());
addMethod(new EzyStartPingScheduleMethod());
addMethod(new EzyGenerateKeyPairMethod());
addMethod(new EzyRsaDecryptMethod());
addMethod(new EzyLogMethod());
addMethod(new EzySetSessionKeyMethod());
}

private void addMethod(EzyMethodProxy method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public final class EzyMethodNames {
public static final String METHOD_RECONNECT = "reconnect";
public static final String METHOD_SET_STATUS = "setStatus";
public static final String METHOD_START_PING_SCHEDULE = "startPingSchedule";
public static final String METHOD_GENERATE_KEY_PAIR = "generateKeyPair";
public static final String METHOD_RSA_DECRYPT = "rsaDecrypt";
public static final String METHOD_LOG = "log";
public static final String METHOD_SET_SESSION_KEY = "setSessionKey";

private EzyMethodNames() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ private EzyClientConfig newConfig(Map params) {
configBuilder.clientName((String) params.get("clientName"));
if(params.containsKey("zoneName"))
configBuilder.zoneName((String) params.get("zoneName"));
if(params.containsKey("enableSSL"))
configBuilder.enableSSL((Boolean) params.get("enableSSL"));
if(params.containsKey("enableDebug"))
configBuilder.enableDebug((Boolean) params.get("enableDebug"));
if(params.containsKey("reconnect")) {
Map reconnect = (Map) params.get("reconnect");
EzyReconnectConfig.Builder reconnectConfigBuilder = configBuilder.reconnectConfigBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.tvd12.ezyfoxerver.client.proxy;

import com.tvd12.ezyfoxerver.client.EzyMethodNames;
import com.tvd12.ezyfoxserver.client.EzyClient;
import com.tvd12.ezyfoxserver.client.constant.EzyConnectionStatus;
import com.tvd12.ezyfoxserver.client.sercurity.EzyKeysGenerator;

import java.security.KeyPair;
import java.util.HashMap;
import java.util.Map;

/**
* Created by tavandung12 on 10/25/18.
*/

public class EzyGenerateKeyPairMethod extends EzyMethodProxy {
@Override
public Object invoke(Map params) {
KeyPair keyPair = EzyKeysGenerator.builder()
.build()
.generate();
byte[] publicKey = keyPair.getPublic().getEncoded();
byte[] privateKey = keyPair.getPrivate().getEncoded();
Map<String, byte[]> answer = new HashMap<>();
answer.put("publicKey", publicKey);
answer.put("privateKey", privateKey);
return answer;
}

@Override
public String getName() {
return EzyMethodNames.METHOD_GENERATE_KEY_PAIR;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.tvd12.ezyfoxerver.client.proxy;

import com.tvd12.ezyfoxerver.client.EzyMethodNames;
import com.tvd12.ezyfoxserver.client.logger.EzyLogger;
import com.tvd12.ezyfoxserver.client.sercurity.EzyAsyCrypt;

import java.util.Map;

/**
* Created by tavandung12 on 10/25/18.
*/

public class EzyLogMethod extends EzyMethodProxy {
@Override
public Object invoke(Map params) throws Exception {
String level = (String)params.getOrDefault("level", "i");
String message = (String)params.get("message");
if(level.equals("w")) {
EzyLogger.warn(message);
}
else if(level.equals("e")) {
EzyLogger.error(message);
}
else if(level.equals("d")) {
EzyLogger.debug(message);
}
else {
EzyLogger.info(message);
}
return Boolean.TRUE;
}

@Override
public String getName() {
return EzyMethodNames.METHOD_LOG;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class EzyMethodProxy {

protected EzyClients clients = EzyClients.getInstance();

public abstract Object invoke(Map params);
public abstract Object invoke(Map params) throws Exception;
public abstract String getName();

public void validate(Map params) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tvd12.ezyfoxerver.client.proxy;

import com.tvd12.ezyfoxerver.client.EzyMethodNames;
import com.tvd12.ezyfoxserver.client.sercurity.EzyAsyCrypt;
import com.tvd12.ezyfoxserver.client.sercurity.EzyKeysGenerator;

import java.security.KeyPair;
import java.util.HashMap;
import java.util.Map;

/**
* Created by tavandung12 on 10/25/18.
*/

public class EzyRsaDecryptMethod extends EzyMethodProxy {
@Override
public Object invoke(Map params) throws Exception {
byte[] message = (byte[])params.get("message");
byte[] privateKey = (byte[])params.get("privateKey");
return EzyAsyCrypt.builder()
.privateKey(privateKey)
.build()
.decrypt(message);
}

@Override
public String getName() {
return EzyMethodNames.METHOD_RSA_DECRYPT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public Object invoke(Map params) {
Map request = (Map) params.get("request");
String cmd = (String) request.get("command");
List data = (List) request.get("data");
boolean encrypted = (Boolean)request.getOrDefault("encrypted", false);
EzyArray array = EzyNativeSerializers.fromList(data);
client.send(EzyCommand.valueOf(cmd), array);
client.send(EzyCommand.valueOf(cmd), array, encrypted);
return Boolean.TRUE;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.tvd12.ezyfoxerver.client.proxy;

import com.tvd12.ezyfoxerver.client.EzyMethodNames;
import com.tvd12.ezyfoxserver.client.EzyClient;
import com.tvd12.ezyfoxserver.client.logger.EzyLogger;

import java.util.Map;

/**
* Created by tavandung12 on 10/25/18.
*/

public class EzySetSessionKeyMethod extends EzyMethodProxy {
@Override
public Object invoke(Map params) throws Exception {
EzyClient client = getClient(params);
byte[] sessionKey = (byte[])params.get("sessionKey");
client.setSessionKey(sessionKey);
return Boolean.TRUE;
}

@Override
public String getName() {
return EzyMethodNames.METHOD_SET_SESSION_KEY;
}
}
49 changes: 43 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
F17E475F269A6C4F00668CED /* EzyUTSocketClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F17E470D269A6C4F00668CED /* EzyUTSocketClient.cpp */; };
F17E4760269A6C4F00668CED /* EzyUdpSocketClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F17E470E269A6C4F00668CED /* EzyUdpSocketClient.cpp */; };
F17E4761269A6C4F00668CED /* EzySocketWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F17E470F269A6C4F00668CED /* EzySocketWriter.cpp */; };
F17E476726A2BFF700668CED /* NSByArray.m in Sources */ = {isa = PBXBuildFile; fileRef = F17E476626A2BFF700668CED /* NSByArray.m */; };
F17E476B26A2C00300668CED /* EzyEncryptionProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = F17E476A26A2C00300668CED /* EzyEncryptionProxy.mm */; };
F17E476F26A2C01500668CED /* EzyNSNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = F17E476D26A2C01500668CED /* EzyNSNumber.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -275,6 +278,12 @@
F17E470E269A6C4F00668CED /* EzyUdpSocketClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EzyUdpSocketClient.cpp; sourceTree = "<group>"; };
F17E470F269A6C4F00668CED /* EzySocketWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EzySocketWriter.cpp; sourceTree = "<group>"; };
F17E4710269A6C4F00668CED /* EzyMainEventsLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EzyMainEventsLoop.h; sourceTree = "<group>"; };
F17E476426A2BFF700668CED /* NSByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSByteArray.h; sourceTree = "<group>"; };
F17E476626A2BFF700668CED /* NSByArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSByArray.m; sourceTree = "<group>"; };
F17E476926A2C00300668CED /* EzyEncryptionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EzyEncryptionProxy.h; sourceTree = "<group>"; };
F17E476A26A2C00300668CED /* EzyEncryptionProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EzyEncryptionProxy.mm; sourceTree = "<group>"; };
F17E476D26A2C01500668CED /* EzyNSNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EzyNSNumber.m; sourceTree = "<group>"; };
F17E476E26A2C01500668CED /* EzyNSNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EzyNSNumber.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -343,16 +352,18 @@
F17E4655269A6C4E00668CED /* client */ = {
isa = PBXGroup;
children = (
F17E476C26A2C01500668CED /* math */,
F17E476826A2C00300668CED /* codec */,
F17E4656269A6C4E00668CED /* serializer */,
F17E4662269A6C4E00668CED /* proxy */,
F17E4665269A6C4E00668CED /* util */,
F17E4668269A6C4E00668CED /* EzyMethodNames.h */,
F17E4669269A6C4E00668CED /* Prefix.pch */,
F17E466B269A6C4E00668CED /* EzyClientProxy.mm */,
F17E4671269A6C4E00668CED /* EzyClientProxy.h */,
F17E466C269A6C4E00668CED /* AppConfigDefine.h */,
F17E466D269A6C4E00668CED /* EzyMethodNames.mm */,
F17E4668269A6C4E00668CED /* EzyMethodNames.h */,
F17E466E269A6C4E00668CED /* exception */,
F17E4671269A6C4E00668CED /* EzyClientProxy.h */,
F17E4672269A6C4E00668CED /* socket */,
);
path = client;
Expand Down Expand Up @@ -389,6 +400,8 @@
children = (
F17E4666269A6C4E00668CED /* EzyNativeStrings.mm */,
F17E4667269A6C4E00668CED /* EzyNativeStrings.h */,
F17E476626A2BFF700668CED /* NSByArray.m */,
F17E476426A2BFF700668CED /* NSByteArray.h */,
);
path = util;
sourceTree = "<group>";
Expand Down Expand Up @@ -727,6 +740,24 @@
path = socket;
sourceTree = "<group>";
};
F17E476826A2C00300668CED /* codec */ = {
isa = PBXGroup;
children = (
F17E476926A2C00300668CED /* EzyEncryptionProxy.h */,
F17E476A26A2C00300668CED /* EzyEncryptionProxy.mm */,
);
path = codec;
sourceTree = "<group>";
};
F17E476C26A2C01500668CED /* math */ = {
isa = PBXGroup;
children = (
F17E476D26A2C01500668CED /* EzyNSNumber.m */,
F17E476E26A2C01500668CED /* EzyNSNumber.h */,
);
path = math;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -756,7 +787,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -862,6 +893,7 @@
F17E4740269A6C4F00668CED /* EzyDataDecoder.cpp in Sources */,
F17E475D269A6C4F00668CED /* EzySocketPool.cpp in Sources */,
F17E472A269A6C4F00668CED /* EzyDataHandlers.cpp in Sources */,
F17E476B26A2C00300668CED /* EzyEncryptionProxy.mm in Sources */,
F17E4750269A6C4F00668CED /* EzyReleasePool.cpp in Sources */,
F17E472E269A6C4F00668CED /* EzyPluginDataHandler.cpp in Sources */,
F17E473F269A6C4F00668CED /* EzyMessage.cpp in Sources */,
Expand All @@ -874,6 +906,7 @@
F17E4752269A6C4F00668CED /* EzyRequest.cpp in Sources */,
F17E472D269A6C4F00668CED /* EzyPluginDataHandlers.cpp in Sources */,
F17E473D269A6C4F00668CED /* EzyUser.cpp in Sources */,
F17E476F26A2C01500668CED /* EzyNSNumber.m in Sources */,
F17E4714269A6C4F00668CED /* EzyNativeDataSerializer.mm in Sources */,
F17E4736269A6C4F00668CED /* EzyZone.cpp in Sources */,
F17E4749269A6C4F00668CED /* EzyPingManager.cpp in Sources */,
Expand Down Expand Up @@ -906,6 +939,7 @@
F17E4757269A6C4F00668CED /* EzyTcpSocketClient.cpp in Sources */,
F17E4746269A6C4F00668CED /* EzyPluginManager.cpp in Sources */,
F17E471E269A6C4F00668CED /* EzyMethodCallException.mm in Sources */,
F17E476726A2BFF700668CED /* NSByArray.m in Sources */,
F17E472B269A6C4F00668CED /* EzyEventHandler.cpp in Sources */,
F17E4739269A6C4F00668CED /* EzyNull.cpp in Sources */,
F17E4747269A6C4F00668CED /* EzyAppManager.cpp in Sources */,
Expand Down Expand Up @@ -966,6 +1000,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -984,7 +1019,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -1039,6 +1074,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -1063,7 +1099,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1094,6 +1130,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -1112,7 +1149,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
10 changes: 3 additions & 7 deletions ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
Expand Down
Loading

0 comments on commit bcead70

Please sign in to comment.