Exemplo n.º 1
0
 public Receiver(ConnectionUDP conn)
 {
     this.conn    = conn;
     uis          = new UDPInputStream(conn);
     this.sender  = conn.sender;
     this.dstIp   = conn.dstIp;
     this.dstPort = conn.dstPort;
 }
Exemplo n.º 2
0
 public ConnectionUDP(Route ro, IPAddress dstIp, int dstPort, int mode, int connectId, ClientControl clientControl)
 {
     this.clientControl = clientControl;
     this.route         = ro;
     this.dstIp         = dstIp;
     this.dstPort       = dstPort;
     this.mode          = mode;
     if (mode == 1)
     {
         //MLog.println("                 发起连接RUDP "+dstIp+":"+dstPort+" connectId "+connectId);
     }
     else if (mode == 2)
     {
         //MLog.println("                 接受连接RUDP "+dstIp+":"+dstPort+" connectId "+connectId);
     }
     this.connectId = connectId;
     try
     {
         sender   = new Sender(this);
         receiver = new Receiver(this);
         uos      = new UDPOutputStream(this);
         uis      = new UDPInputStream(this);
         if (mode == 2)
         {
             ro.createTunnelProcessor().process(this);
         }
     }
     catch (Exception e)
     {
         e.printStackTrace();
         connected = false;
         route.connTable.remove(connectId);
         e.printStackTrace();
         //#MLog.println("                 连接失败RUDP "+connectId);
         lock (this)
         {
             notifyAll();
         }
         throw e;
     }
     //#MLog.println("                 连接成功RUDP "+connectId);
     lock (this)
     {
         notifyAll();
     }
 }
Exemplo n.º 3
0
        public PortMapProcess(MapClient mapClient, Route route, Socket srcSocket, String serverAddress2, int serverPort2, string password_proxy_md5,
                              string dstAddress, int dstPort)
        {
            this.mapClient     = mapClient;
            this.serverAddress = serverAddress2;
            this.serverPort    = serverPort2;

            this.srcSocket          = srcSocket;
            this.password_proxy_md5 = password_proxy_md5;

            try {
                srcIs = new DataInputStream(srcSocket.getInputStream());
                srcOs = new DataOutputStream(srcSocket.getOutputStream());
                conn  = route.getConnection(serverAddress, serverPort, null);
                tis   = conn.uis;
                tos   = conn.uos;

                JSONObject requestJson = new JSONObject();
                requestJson.put("dst_address", dstAddress);
                requestJson.put("dst_port", dstPort);
                requestJson.put("password_proxy_md5", password_proxy_md5);
                byte[] requestData = requestJson.toJSONString().getBytes("utf-8");
                tos.write(requestData, 0, requestData.length);


                final Pipe p1 = new Pipe();
                final Pipe p2 = new Pipe();


                byte[] responeData = tis.read2();

                String     hs          = new String(responeData, "utf-8");
                JSONObject responeJSon = JSONObject.parseObject(hs);
                int        code        = responeJSon.getIntValue("code");
                String     message     = responeJSon.getString("message");
                String     uimessage   = "";
                if (code == Constant.code_success)
                {
                    Route.es.execute(new Runnable()
                    {
                        @Override