Example #1
0
 public Sender(ConnectionUDP conn)
 {
     this.conn    = conn;
     uos          = new UDPOutputStream(conn);
     receiver     = conn.receiver;
     this.dstIp   = conn.dstIp;
     this.dstPort = conn.dstPort;
 }
 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();
     }
 }
Example #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