/** {@inheritDoc} */ public void detach(MonitoredVm vm) throws MonitorException { RemoteMonitoredVm rmvm = (RemoteMonitoredVm) vm; rmvm.detach(); try { remoteHost.detachVm(rmvm.getRemoteVm()); } catch (RemoteException e) { throw new MonitorException( "Remote Exception detaching from " + vm.getVmIdentifier().toString(), e); } }
/** {@inheritDoc} */ public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval) throws MonitorException { VmIdentifier nvmid = null; try { nvmid = hostId.resolve(vmid); RemoteVm rvm = remoteHost.attachVm(vmid.getLocalVmId(), vmid.getMode()); RemoteMonitoredVm rmvm = new RemoteMonitoredVm(rvm, nvmid, timer, interval); rmvm.attach(); return rmvm; } catch (RemoteException e) { throw new MonitorException("Remote Exception attaching to " + nvmid.toString(), e); } catch (URISyntaxException e) { /* * the VmIdentifier is expected to be a valid and should resolve * easonably against the host identifier. A URISyntaxException * here is most likely a programming error. */ throw new IllegalArgumentException("Malformed URI: " + vmid.toString(), e); } }
public void GetClientCommand() throws Exception { // +----+-----+-------+------+----------+----------+ // |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | // +----+-----+-------+------+----------+----------+ // | 1 | 1 | X'00' | 1 | Variable | 2 | // +----+-----+-------+------+----------+----------+ int Addr_Len; SOCKS_Version = GetByte(); Command = GetByte(); RSV = GetByte(); ATYP = GetByte(); // Address Addr_Len = ADDR_Size[ATYP]; DST_Addr[0] = GetByte(); // Shift Out " " 0x0e if (ATYP == 0x03) { Addr_Len = DST_Addr[0] + 1; // | len | [0]SO | 192 .... | } for (int i = 1; i < Addr_Len; i++) { DST_Addr[i] = GetByte(); } // Port DST_Port[0] = GetByte(); DST_Port[1] = GetByte(); // --------------------- if (SOCKS_Version != SOCKS5_Version) { Logs.Println( Logger.ERROR, "SOCKS 5 - Incorrect SOCKS Version of Command: " + SOCKS_Version, true); Refuse_Command((byte) 0xFF); throw new Exception("Incorrect SOCKS Version of Command: " + SOCKS_Version); } if ((Command < SC_CONNECT) || (Command > SC_UDP)) { Logs.Println( Logger.ERROR, "SOCKS 5 - GetClientCommand() - Unsupported Command : \"" + commName(Command) + "\"", true); Refuse_Command((byte) 0x07); throw new Exception("SOCKS 5 - Unsupported Command: \"" + Command + "\""); } if (ATYP == 0x04) { Logs.Println( Logger.ERROR, "SOCKS 5 - GetClientCommand() - Unsupported Address Type - IP v6", true); Refuse_Command((byte) 0x08); throw new Exception("Unsupported Address Type - IP v6"); } if ((ATYP >= 0x04) || (ATYP <= 0)) { Logs.Println( Logger.ERROR, "SOCKS 5 - GetClientCommand() - Unsupported Address Type: " + ATYP, true); Refuse_Command((byte) 0x08); throw new Exception("SOCKS 5 - Unsupported Address Type: " + ATYP); } if (!Calculate_Address()) { // Gets the IP Address Refuse_Command((byte) 0x04); // Host Not Exists... throw new Exception("SOCKS 5 - Unknown Host/IP address '" + RemoteHost.toString() + "'"); } Logs.Println( Logger.INFO, "SOCKS 5 - Accepted SOCKS5 Command: \"" + commName(Command) + "\"", true); }