public void ModifyVmNatPortForward(VmId vm, int natNo, string ruleName, PortType portType, string hostIp, int hostPort, string guestIp, int guestPort)
        {
            if (vm == null)
            {
                throw new ArgumentNullException(nameof(vm), nameof(ModifyVmNatPortForward) + " requires a target");
            }
            if (vm == "")
            {
                throw new ArgumentException(nameof(ModifyVmNatPortForward) + " requires a target", nameof(vm));
            }
            if (natNo < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(natNo), natNo, "natNo is 1-based");
            }

            ruleName = ruleName ?? "";
            hostIp   = hostIp ?? "";
            guestIp  = guestIp ?? "";

            var rule = $"{ruleName},{portType.ToString().ToLowerInvariant()},{hostIp},{hostPort},{guestIp},{guestPort}";
            var exit = Proc.ExecIn(null, VBoxManagePath, $"modifyvm {vm} --natpf{natNo} \"{rule}\"", stdout => { }, stderr => { }, ProcessWindowStyle.Hidden);

            if (exit != 0)
            {
                throw new ToolResultSyntaxException("VBoxManage modifyvm .... --natpf...", "Returned nonzero");
            }
        }
예제 #2
0
        public override void WriteToXML(XElement root)
        {
            XElement xmldatatype = new XElement("PortDefenition");

            base.WriteToXML(xmldatatype);
            xmldatatype.Add(new XElement("InterfaceGUID", InterfaceGUID.ToString("B")));
            xmldatatype.Add(new XElement("PortType", PortType.ToString()));
            root.Add(xmldatatype);
        }
예제 #3
0
 public virtual void SerializeNetwork(XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartAttribute("Id");
     xmlWriter.WriteValue(Id.ToString());
     xmlWriter.WriteEndAttribute();
     xmlWriter.WriteStartAttribute("PortType");
     xmlWriter.WriteValue(PortType.ToString());
     xmlWriter.WriteEndAttribute();
     xmlWriter.WriteStartAttribute("ParentNodeId");
     xmlWriter.WriteValue(ParentNode.Guid.ToString());
     xmlWriter.WriteEndAttribute();
 }
예제 #4
0
        public override string ToString()// Manufacturer-Name-Type-(Port)
        {
            StringBuilder DeviceFullName = new StringBuilder();

            DeviceFullName.AppendFormat(Manufacturer);
            DeviceFullName.AppendFormat(Name);
            DeviceFullName.AppendFormat(Type.ToString());
            DeviceFullName.Append('(');
            DeviceFullName.AppendFormat(PortType.ToString());
            DeviceFullName.Append(')');

            return(DeviceFullName.ToString());
        }
예제 #5
0
    void SetPorts()
    {
        Ports.SetActive(true);
        MultipleWidgetTopHalf.SetActive(false);
        InitializePortSets();
        _portList = new List <string>();

        if (!_modSettings.DebugModeForceAllPossiblePorts)
        {
            var portset = Random.Range(0, _modSettings.EnableExtendedPorts ? _portGroups.Count : 2);
            foreach (var set in _portGroups[portset])
            {
                if (!_modSettings.DebugModeForceAllPortsInCurrentSet && !(Random.value > 0.5f))
                {
                    continue;
                }
                _presentPorts |= set;
                _portLookup[set].SetActive(true);
                if (_portFiller.ContainsKey(set))
                {
                    _portFiller[set].SetActive(false);
                }
                _portList.Add(set.ToString());
            }

            //DebugLog("Using ports from the following port set: {0}", _portGroupNames[portset]);
            DebugLog("Ports ({0}): {1}", _portGroupNames[portset], _presentPorts.ToString());
        }
        else
        {
            DebugLog("Forcing EVERY possible port.");
            foreach (var port in _portLookup.Keys)
            {
                _presentPorts |= port;
                _portLookup[port].SetActive(true);
                _portList.Add(port.ToString());
                if (_portFiller.ContainsKey(port))
                {
                    _portFiller[port].SetActive(false);
                }
            }
            DebugLog("Ports ({0}): {1}", "Everything", _presentPorts.ToString());
        }
        //Debug.LogFormat("[PortWidget] Randomizing Port Widget: {0}", _presentPorts.ToString());
    }
예제 #6
0
 public override bool Read(PortType portType, uint port, out BitArray bitArray)
 {
     uint value = 0;
     bool isOk;
     bitArray = new BitArray(Channels,false);
     if (!IsOpen)
         return false;
     if (portType == PortType.DO)
     {
         isOk = DOReadPort(port, out value);
         RaisedOnReadEvent(new IOCardEventArgs(port,
                 Gadget.IntToBitArray(value, Channels), isOk));
         if (isOk)
         {
             bitArray = Gadget.IntToBitArray(value, Channels);
             return true;
         }
         else
         {
             bitArray = new BitArray(Channels, false);
             throw new APXExeception(String.Format("{0} Read Fail.", portType.ToString()));
         }
     }
     else if (portType == PortType.DI)
     {
         isOk = DIReadPort(port, out value);
         if (isOk)
         {
             bitArray = Gadget.IntToBitArray(value, 32);
             return true;
         }
         else
         {
             bitArray = new BitArray(32, false);
             throw new APXExeception("DI Read Fail.");
         }
     }
     else
     {
         bitArray = new BitArray(32, false);
         throw new APXExeception("PortType: {0} is not Support.");
     }
 }
예제 #7
0
 public static bool IsPortPresent(this KMBombInfo bombInfo, PortType portType)
 {
     return(bombInfo.IsPortPresent(portType.ToString()));
 }
예제 #8
0
 public static int GetPortCount(this KMBombInfo bombInfo, PortType portType)
 {
     return(bombInfo.GetPortCount(portType.ToString()));
 }
예제 #9
0
    public bool Connect(Module module)
    {
        if (module.portType != type)
        {
            Debug.LogWarning("Type Mismatch: " + module.portType.ToString() + "|" + gameObject.name + " " + module.gameObject.name + "|" + type.ToString());
            return(false);
        }

        if (module == null)
        {
            Debug.LogWarning("Attempted to connect null module");
            return(false);
        }

        if (this.module != null)
        {
            Debug.LogWarning("Port: " + gameObject.name + " Already has module connected: " + module.name);
            return(false);
        }

        this.module = module;

        module.transform.position = transform.position;
        module.transform.rotation = transform.rotation;
        module.transform.SetParent(transform);

        float zpos = 0;

        if (transform.localPosition.y <= 0)
        {
            zpos = transform.localPosition.y;
        }
        else
        {
            zpos = 2 * transform.localPosition.y;
        }

        module.transform.localPosition = new Vector3
                                             (module.transform.localPosition.x,
                                             module.transform.localPosition.y,
                                             zpos / 10f);


        module.Register(this);
        module.OnConnect();
        root.OnPortConnected(module);
        return(true);
    }