mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 01:20:25 +08:00
中移项目--号认证注册登录请求
This commit is contained in:
@@ -59,10 +59,19 @@ public class BC_API {
|
||||
public NetworkResponse login(LoginWithSignRequest request){
|
||||
return doRequest(this.ip,this.port,this.sslPort,request,"user","login");
|
||||
}
|
||||
|
||||
public NetworkResponse tokenLogin(LoginWithSignRequest request){
|
||||
return doRequest(this.ip,this.port,this.sslPort,request,"user","tokenLogin");
|
||||
}
|
||||
|
||||
public NetworkResponse login(LoginRequest request){
|
||||
return doRequest(this.ip,this.port,this.sslPort,request,"user","login");
|
||||
}
|
||||
|
||||
public NetworkResponse tokenRegister(TokenRegisterRequest request){
|
||||
return doRequest(this.ip,this.port,this.sslPort,request,"user","tokenRegister");
|
||||
}
|
||||
|
||||
public NetworkResponse register(RegisterWithSignRequest request){
|
||||
return doRequest(this.ip,this.port,this.sslPort,request,"user","register");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package VMSConnection.Model;
|
||||
|
||||
import VMSConnection.TCPNet.Message.BaseStruct;
|
||||
|
||||
public class TokenRegisterRequest extends BaseStruct {
|
||||
public int ID;
|
||||
public String Name;
|
||||
public String Password;
|
||||
public String Phone;
|
||||
public String Invitation;
|
||||
public String Email;
|
||||
public String DeviceInfo;
|
||||
public String Certificate;
|
||||
public String Pubkey;
|
||||
public int IsRevoked;
|
||||
public int UGroupID;
|
||||
public String TimeStamp;
|
||||
// public byte[] Signature;
|
||||
public byte[] EncryptedPwd;
|
||||
|
||||
public String token;
|
||||
|
||||
public TokenRegisterRequest(int ID, String name, String password, String phone,
|
||||
String invitation, String email, String deviceInfo,
|
||||
String certification, String pubkey,int isRevoked,
|
||||
int UGroupID, String timeStamp, byte[] signature,String token) {
|
||||
this.ID = ID;
|
||||
Name = name;
|
||||
Password = password;
|
||||
Phone = phone;
|
||||
Invitation = invitation;
|
||||
Email = email;
|
||||
DeviceInfo = deviceInfo;
|
||||
Certificate = certification;
|
||||
this.Pubkey=pubkey;
|
||||
IsRevoked = isRevoked;
|
||||
this.UGroupID = UGroupID;
|
||||
TimeStamp = timeStamp;
|
||||
EncryptedPwd = signature;
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class SSL {
|
||||
result.add("");
|
||||
result.add(not_encrypted);
|
||||
result.add(400);
|
||||
result.add(null);
|
||||
result.add(data);
|
||||
// json转java对象
|
||||
SSL_Message res=new SSL_Message();
|
||||
res.unJson(data,res);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package Socks5Test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class Socks5HandShakeTest {
|
||||
|
||||
@Test
|
||||
public void handShakeTest() throws IOException {
|
||||
Socket socket = new Socket("113.105.122.178", 13889);
|
||||
OutputStream outputStream = socket.getOutputStream();
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
|
||||
byte[] buffer = new byte[256];
|
||||
buffer[0] = 0x05; // Socks Version 5
|
||||
buffer[1] = 0x01; // Number of authentication methods supported
|
||||
buffer[2] = 0x00; // No authentication required
|
||||
outputStream.write(buffer, 0, 3);
|
||||
|
||||
inputStream.read(buffer, 0, 2);
|
||||
if (buffer[0] != 0x05 || buffer[1] != 0x00) {
|
||||
throw new IOException("Failed to connect to socks5 server");
|
||||
}
|
||||
|
||||
String remoteAddress = "113.105.122.178";
|
||||
int remotePort = 13889;
|
||||
|
||||
buffer[0] = 0x05; // Socks Version 5
|
||||
buffer[1] = 0x01; // Connect command
|
||||
buffer[2] = 0x00; // Reserved
|
||||
buffer[3] = 0x03; // Domain name type
|
||||
buffer[4] = (byte) remoteAddress.length(); // Domain name length
|
||||
System.arraycopy(remoteAddress.getBytes(), 0, buffer, 5, remoteAddress.length());
|
||||
int port = remotePort;
|
||||
buffer[5 + remoteAddress.length()] = (byte) ((port >> 8) & 0xff); // Port number
|
||||
buffer[6 + remoteAddress.length()] = (byte) (port & 0xff);
|
||||
outputStream.write(buffer, 0, remoteAddress.length() + 7);
|
||||
|
||||
inputStream.read(buffer, 0, 10);
|
||||
if (buffer[0] != 0x05 || buffer[1] != 0x00) {
|
||||
throw new IOException("Failed to connect to remote server");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Now the socket is ready to use to communicate with the remote server
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,11 @@ public class TestAPI {
|
||||
// }
|
||||
// todo: VMS最新版不支持响应验证码,此功能需MIS进行支持。——2022.03.19
|
||||
public static void main(String[] args){
|
||||
String username="newBlood2";
|
||||
String email="2hsaosusaisinos@163.com";
|
||||
String phone="15239970973";
|
||||
String username="newBlood222";
|
||||
String email="2hsaosu11saisinos@163.com";
|
||||
String phone="15012345678";
|
||||
// String passwd="password";
|
||||
String passwd="fukinngTestHash";
|
||||
String passwd="Pkusz@123";
|
||||
String machineInfo="Android-GuessMe";
|
||||
String smscode = "";
|
||||
int userID=1;
|
||||
@@ -62,8 +62,8 @@ public class TestAPI {
|
||||
System.out.println("raw text: "+username);
|
||||
// return;
|
||||
|
||||
boolean _regis=false;
|
||||
boolean _login=true;
|
||||
boolean _regis=true;
|
||||
boolean _login=false;
|
||||
boolean _getvpninfo=false;
|
||||
boolean _getsmscode=false;
|
||||
boolean _deleteMachine=false;
|
||||
@@ -77,20 +77,24 @@ public class TestAPI {
|
||||
// sig=Base64Helper.BlockChain_Base64Encode(sig).getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
BC_API bc_api=new BC_API();
|
||||
bc_api.ip="121.15.171.89"; // gdcni17
|
||||
bc_api.ip="113.105.122.180"; // gdcni17
|
||||
|
||||
// 构造注册请求包 13294184003
|
||||
if(_regis){
|
||||
RegisterWithSignRequest request=new RegisterWithSignRequest(userID,username,passwd,
|
||||
phone,"1234",email,"dev","",
|
||||
pubkey,0,0,"1625142358",sig);
|
||||
TokenRegisterRequest registerRequest = new TokenRegisterRequest(userID,username,passwd,
|
||||
phone,"v2x2023",email,"dev","",
|
||||
pubkey,0,0,"1625142358",sig,"");
|
||||
try {
|
||||
System.out.println("register request: "+request.toJson());
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 注册
|
||||
NetworkResponse networkResponse=bc_api.register(request);
|
||||
// NetworkResponse networkResponse=bc_api.register(request);
|
||||
NetworkResponse networkResponse = bc_api.tokenRegister(registerRequest);
|
||||
try {
|
||||
System.out.println("注册应答: "+networkResponse.toJson());
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LogicFaceTest {
|
||||
interest.setName(name);
|
||||
|
||||
LogicFace face=new LogicFace();
|
||||
face.initWithTcp("127.0.0.1",60000);
|
||||
face.initWithTcp("113.105.122.178",13889);
|
||||
face.sendInterest(interest);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class LogicFaceTest {
|
||||
interest.setName(name);
|
||||
|
||||
LogicFace face=new LogicFace();
|
||||
face.initWithTcp("127.0.0.1",60000);
|
||||
face.initWithTcp("113.105.122.178",13889);
|
||||
face.sendInterest(interest);
|
||||
|
||||
// 等待两秒钟,接收兴趣包
|
||||
@@ -118,12 +118,12 @@ public class LogicFaceTest {
|
||||
data.setName(name);
|
||||
|
||||
LogicFace face=new LogicFace();
|
||||
face.initWithTcp("127.0.0.1",60000);
|
||||
face.initWithTcp("113.105.122.178",13889);
|
||||
face.sendData(data);
|
||||
|
||||
// 等待两秒钟,接收数据包
|
||||
try {
|
||||
Data data1 = face.receiveData(6000);
|
||||
Data data1 = face.receiveData(2000);
|
||||
System.out.println(Arrays.toString(
|
||||
new SelfEncodingBase().selfWireEncode(data1).getRaw()));
|
||||
}catch (Exception e){
|
||||
@@ -160,23 +160,38 @@ public class LogicFaceTest {
|
||||
CPacket cPacket=new CPacket();
|
||||
byte[] value={(byte)132,(byte)221,(byte)223,(byte)25};
|
||||
cPacket.payload.setValue(value);
|
||||
// Identifier name=new Identifier("/wefree");
|
||||
// Identifier nameTo=new Identifier("/0%2F/0min/0vpnserver/0inner/40/0eyJNSUQiOiIiLCJNYWMiOiIiLCJCZWlEb3UiOiIiLCJHUFMiOiIiLCJTSU0iOiIifQ");
|
||||
Identifier name=new Identifier("/wefree");
|
||||
Identifier nameTo=new Identifier("/wf");
|
||||
cPacket.setSrcIdentifier(name);
|
||||
cPacket.setDstIdentifier(nameTo);
|
||||
|
||||
LogicFace face=new LogicFace();
|
||||
face.initWithTcp("121.15.171.82",13899);
|
||||
face.initWithTcp("113.105.122.178",13889);
|
||||
face.sendCPacket(cPacket);
|
||||
|
||||
|
||||
|
||||
|
||||
// 等待两秒钟,接收推式包
|
||||
try {
|
||||
CPacket cPacket1 = face.receiveCPacket(100000);
|
||||
CPacket cPacket1 = face.receiveCPacket(2000);
|
||||
System.out.println(Arrays.toString(
|
||||
new SelfEncodingBase().selfWireEncode(cPacket1).getRaw()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//
|
||||
// face.sendCPacket(cPacket);
|
||||
//
|
||||
// try {
|
||||
// CPacket cPacket1 = face.receiveCPacket(5000);
|
||||
// System.out.println(Arrays.toString(
|
||||
// new SelfEncodingBase().selfWireEncode(cPacket1).getRaw()));
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TcpTransportTest {
|
||||
// 初始化一个tcp连接
|
||||
TcpTransport tcpTransport = new TcpTransport();
|
||||
SocketChannel socketChannel = SocketChannel.open();
|
||||
SocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 60000);
|
||||
SocketAddress socketAddress = new InetSocketAddress("113.105.122.178", 13889);
|
||||
socketChannel.connect(socketAddress);
|
||||
tcpTransport.init(socketChannel);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TcpTransportTest {
|
||||
// 初始化一个tcp连接
|
||||
TcpTransport tcpTransport = new TcpTransport();
|
||||
SocketChannel socketChannel = SocketChannel.open();
|
||||
SocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 60000);
|
||||
SocketAddress socketAddress = new InetSocketAddress("113.105.122.178", 13889);
|
||||
socketChannel.connect(socketAddress);
|
||||
tcpTransport.init(socketChannel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user