Example #1
0
        private INetworkInterface CreateNetworkInterfaceIfNotExists(INetwork network, IPublicIPAddress publicIPAddress)
        {
            messageContainer.AddInformationMessage("Configuring network interface...");

            String            interfaceName    = "azureAutoEngine_NetworkInterface";
            INetworkInterface networkInterface = azureConnection.AzureLink.NetworkInterfaces.GetByResourceGroup(AzureConnectionUtility.ResourceGroup, interfaceName);

            if (networkInterface == null)
            {
                messageContainer.AddInformationMessage("Creating network interface...");
                networkInterface = azureConnection.AzureLink.NetworkInterfaces.Define("azureAutoEngine_NetworkInterface")
                                   .WithRegion(AzureConnectionUtility.Region)
                                   .WithExistingResourceGroup(AzureConnectionUtility.ResourceGroup)
                                   .WithExistingPrimaryNetwork(network)
                                   .WithSubnet("azureAutoEngine_Subnet")
                                   .WithPrimaryPrivateIPAddressDynamic()
                                   .WithExistingPrimaryPublicIPAddress(publicIPAddress)
                                   .Create();
                messageContainer.AddInformationMessage("Network interface created...");
            }

            messageContainer.AddInformationMessage("Network interface configured...");

            return(networkInterface);
        }
Example #2
0
	public PacketReceiver(INetworkInterface netInterface)
	{
		packetReader = new PacketReader();

		this.netInterface = netInterface;
		netInterface.onReceive += OnReceiveData;
	}
Example #3
0
        public static void PrintNetworkInterface(INetworkInterface resource)
        {
            var info = new StringBuilder();

            info.Append("NetworkInterface: ").Append(resource.Id)
            .Append("Name: ").Append(resource.Name)
            .Append("\n\tResource group: ").Append(resource.ResourceGroupName)
            .Append("\n\tRegion: ").Append(resource.Region)
            .Append("\n\tTags: ").Append(FormatDictionary(resource.Tags))
            .Append("\n\tInternal DNS name label: ").Append(resource.InternalDnsNameLabel)
            .Append("\n\tInternal FQDN: ").Append(resource.InternalFqdn)
            .Append("\n\tInternal domain name suffix: ").Append(resource.InternalDomainNameSuffix)
            .Append("\n\tNetwork security group: ").Append(resource.NetworkSecurityGroupId)
            .Append("\n\tApplied DNS servers: ").Append(FormatCollection(resource.AppliedDnsServers))
            .Append("\n\tDNS server IPs: ");

            // Output dns servers
            foreach (var dnsServerIp in resource.DnsServers)
            {
                info.Append("\n\t\t").Append(dnsServerIp);
            }

            info.Append("\n\t IP forwarding enabled: ").Append(resource.IsIpForwardingEnabled)
            .Append("\n\tMAC Address:").Append(resource.MacAddress)
            .Append("\n\tPrivate IP:").Append(resource.PrimaryPrivateIp)
            .Append("\n\tPrivate allocation method:").Append(resource.PrimaryPrivateIpAllocationMethod)
            .Append("\n\tPrimary virtual network ID: ").Append(resource.PrimaryIpConfiguration.NetworkId)
            .Append("\n\tPrimary subnet name:").Append(resource.PrimaryIpConfiguration.SubnetName);

            Console.WriteLine(info.ToString());
        }
Example #4
0
 private void SendProcessedFrame(IExternal reporter, INetworkInterface sender, byte[] buffer)
 {
     lock (innerLock)
     {
         wiresharkSender.SendProcessedFrames(buffer);
     }
 }
Example #5
0
 public ReactiveLiveBit(INetworkInterface networkInterface)
 {
     _networkInterface = networkInterface;
     _timer            = Observable
                         .Interval(TimeSpan.FromSeconds(1))
                         .Subscribe(x => SendLiveBit());
 }
Example #6
0
 private void AddInterface(INetworkLog <INetworkInterface> reporter, INetworkInterface iface)
 {
     lock (innerLock)
     {
         if (observedInterfaces.ContainsKey(reporter))
         {
             if (!observedInterfaces[reporter].Contains(iface))
             {
                 observedInterfaces[reporter].Add(iface);
                 wiresharkSender.TryOpenWireshark();
                 reporter.FrameTransmitted += SendTransmittedFrame;
                 reporter.FrameProcessed   += SendTransmittedFrame;
             }
             else
             {
                 if (!wiresharkSender.TryOpenWireshark())
                 {
                     throw new RecoverableException("The interface is already being logged in this Wireshark instance.");
                 }
             }
         }
         else
         {
             observedInterfaces.Add(reporter, new List <INetworkInterface>()
             {
                 iface
             });
             wiresharkSender.TryOpenWireshark();
             reporter.FrameTransmitted += SendTransmittedFrame;
             reporter.FrameProcessed   += SendTransmittedFrame;
         }
     }
 }
Example #7
0
        /*
         #define MAXLEN_PHYSADDR 8
         * typedef struct _MIB_IPNETROW {
         * DWORD dwIndex;
         * DWORD dwPhysAddrLen;
         * BYTE bPhysAddr[MAXLEN_PHYSADDR];
         * DWORD dwAddr;
         * DWORD dwType;
         * } MIB_IPNETROW, *PMIB_IPNETROW;
         */
        internal ArpEntry(byte[] data, int offset, INetworkInterface associatedAdapter)
        {
            m_data = new byte[SIZE];
            Buffer.BlockCopy(data, offset, m_data, 0, SIZE);

            m_adapter = associatedAdapter;
        }
    /// <summary>
    /// 网络初始化
    /// </summary>
    /// <typeparam name="TProtocol">协议处理类</typeparam>
    /// <typeparam name="TSocket">Socket类</typeparam>
    /// <param name="protocolType">通讯协议</param>
    public static void Init <TProtocol, TSocket>(ProtocolType protocolType = ProtocolType.Tcp) where TProtocol : INetworkInterface, new() where TSocket : SocketBase, new()
    {
        s_network = new TProtocol();
        s_network.m_socketService = new TSocket();

        NetInit();
    }
Example #9
0
        private void NetworkInterface_OnGetMiningParameterStatus(INetworkInterface sender, bool success)
        {
            if (success)
            {
                if (m_isCurrentChallengeStopSolving)
                {
                    IsPause = true;
                }

                else if (IsPause)
                {
                    if (m_failedScanCount > m_pauseOnFailedScan)
                    {
                        m_failedScanCount = 0;
                    }

                    IsPause = false;
                }
            }
            else
            {
                m_failedScanCount++;

                if (m_failedScanCount > m_pauseOnFailedScan)
                {
                    IsPause = true;
                }
            }
        }
        public override ILoadBalancer UpdateResource(ILoadBalancer resource)
        {
            String backendName  = resource.Backends.Values.First().Name;
            String frontendName = resource.Frontends.Values.First().Name;

            var nics = new List <INetworkInterface>();

            foreach (string nicId in resource.Backends[backendName].BackendNicIPConfigurationNames.Keys)
            {
                nics.Add(networks.Manager.NetworkInterfaces.GetById(nicId));
            }
            INetworkInterface nic1 = nics[0];
            INetworkInterface nic2 = nics[1];

            // Remove the NIC associations
            nic1.Update()
            .WithoutLoadBalancerBackends()
            .WithoutLoadBalancerInboundNatRules()
            .Apply();
            Assert.Empty(nic1.PrimaryIPConfiguration.ListAssociatedLoadBalancerBackends());

            nic2.Update()
            .WithoutLoadBalancerBackends()
            .WithoutLoadBalancerInboundNatRules()
            .Apply();
            Assert.Empty(nic2.PrimaryIPConfiguration.ListAssociatedLoadBalancerBackends());

            // Update the load balancer
            var existingPips     = loadBalancerHelper.EnsurePIPs(pips);
            IPublicIPAddress pip = resource.Manager.PublicIPAddresses.GetByResourceGroup(
                loadBalancerHelper.GroupName,
                loadBalancerHelper.PipNames[1]);

            resource = resource.Update()
                       .UpdatePublicFrontend(frontendName)
                       .WithExistingPublicIPAddress(pip)
                       .Parent()
                       .WithoutLoadBalancingRule("rule1")
                       .WithoutInboundNatRule("natrule1")
                       .WithTag("tag1", "value1")
                       .WithTag("tag2", "value2")
                       .Apply();

            Assert.True(resource.Tags.ContainsKey("tag1"));
            Assert.Empty(resource.InboundNatRules.Values);

            // Verify frontends
            Assert.Single(resource.PublicFrontends.Values);
            Assert.Empty(resource.PrivateFrontends.Values);
            Assert.True(resource.Frontends.ContainsKey(frontendName));
            var frontend = resource.Frontends[frontendName];

            Assert.True(frontend.IsPublic);
            var publicFrontend = (ILoadBalancerPublicFrontend)frontend;

            Assert.Equal(pip.Id, publicFrontend.PublicIPAddressId, ignoreCase: true);

            return(resource);
        }
Example #11
0
        private string GetInterfaceDetails(INetworkInterface networkInterface)
        {
            var active = networkInterface.IsActive ? "true" : "false";

            return($"Name: {networkInterface.Name}\n" +
                   $"Description: {networkInterface.Description}\n" +
                   $"Active: {active}\n\n");
        }
Example #12
0
 public LiveBit(INetworkInterface networkInterface)
 {
     _networkInterface = networkInterface;
     _timer            = new Timer(1000);
     _timer.Elapsed   += SendLiveBit;
     _timer.AutoReset  = true;
     _timer.Enabled    = true;
 }
Example #13
0
 /// <summary>
 /// Creates a new IPForwardEntry usable for the specified adapter
 /// </summary>
 /// <param name="adapter">Local NetworkInterface for which this entry will be used</param>
 public IPForwardEntry(INetworkInterface adapter)
 {
     m_data    = new byte[SIZE];
     Metric2   = Metric3 = Metric4 = Metric5 = 0xffffffff;
     m_adapter = adapter;
     Protocol  = IPProtocol.NetworkManagement;
     Policy    = 0;
 }
Example #14
0
        internal IPForwardEntry(byte[] data, int offset, INetworkInterface associatedAdapter)
        {
            m_data = new byte[SIZE];
            Buffer.BlockCopy(data, offset, m_data, 0, SIZE);
            Metric2 = Metric3 = Metric4 = Metric5 = 0xffffffff;

            m_adapter = associatedAdapter;
        }
    /// <summary>
    /// 网络初始化
    /// </summary>
    /// <typeparam name="TProtocol">协议处理类</typeparam>
    /// <typeparam name="TSocket">Socket类</typeparam>
    /// <param name="protocolType">通讯协议</param>
    public static void Init <TProtocol, TSocket>(ProtocolType protocolType = ProtocolType.Tcp) where TProtocol : INetworkInterface, new () where TSocket : SocketBase, new()
    {
        s_network = new TProtocol();
        s_network.m_socketService = new TSocket();

        //ApplicationManager.s_OnApplicationOnGUI += GUI;
        NetInit();
    }
Example #16
0
 private void UnsubscribeFromClientEvents(INetworkInterface client_)
 {
     client_.Disconnected      -= ClientDisconnectEventHandler;
     client_.ConnectionError   -= ClientConnectionErrorEventHandler;
     client_.MessageReceived   -= ClientReceiveMessageEventHandler;
     client_.KeepAliveReceived -= ClientReceiveKeepAliveEventHandler;
     client_.ReceiveError      -= ClientReceiveErrorEventHandler;
 }
 internal NetworkConnection(INetworkInterface networkInterface, int connectionId)
 {
     NetworkInterface = networkInterface;
     MessageHandlers  = networkInterface.MessageHandlers;
     Status           = ConnectionStatus.Connecting;
     Id          = connectionId;
     connectTask = new TaskCompletionSource <object>();
 }
        public OcularPlaneClient(string host, int port)
        {
            var uri      = new Uri($"net.tcp://{host}:{port}");
            var endpoint = new EndpointAddress(uri);
            var factory  = new ChannelFactory <INetworkInterface>(new NetTcpBinding(), endpoint);

            _proxy = factory.CreateChannel();
        }
 internal NetworkGameClient(NetworkConnection connection)
 {
     connectionTask = new TaskCompletionSource <object>();
     connectionTask.SetResult(new object());
     NetworkInterface = connection.NetworkInterface;
     Connection       = connection;
     InitConnection(connection);
 }
 public NetworkGameClient(Type interfaceType, NetworkClientConfig config)
 {
     NetworkInterface = (INetworkInterface)Activator.CreateInstance(interfaceType);
     NetworkInterface.OnPeerDisconnected += OnPeerDisconnected;
     NetworkInterface.Initialize(new NetworkInterfaceConfiguration {
         Type = NetworkInterfaceType.Client
     });
 }
Example #21
0
        public async Task <bool> DeleteAsync(INetworkInterface networkInterface)
        {
            Ensure.NotNull(networkInterface, nameof(networkInterface));

            return(await db.NetworkInterfaces.PatchAsync(networkInterface.Id, new[] {
                Change.Replace("deleted", Func("NOW"))
            }, condition : IsNull("deleted")) > 0);
        }
        public ReactiveLiveBit(INetworkInterface networkInterface, IScheduler scheduler = null)
        {
            var timerScheduler = scheduler ?? Scheduler.Default;

            _networkInterface = networkInterface;
            _timer            = Observable
                                .Interval(TimeSpan.FromSeconds(1), timerScheduler)
                                .Subscribe(x => SendLiveBit());
        }
        VmNicDto CreateNicDto(INetworkInterface nic)
        {
            var result = new VmNicDto()
            {
                Name = nic.Name
            };

            return(result);
        }
        /// <summary>
        /// Causes the ClientConnected event to be fired
        /// </summary>
        /// <param name="client_">The client connection object to pass as the argument when the event fires</param>
        public void InvokeClientConnected(INetworkInterface client_)
        {
            if (null == ClientConnected)
            {
                return;
            }

            ClientConnected(this, client_);
        }
Example #25
0
        /// <summary>
        /// Creates an instance of an ArpEntry
        /// </summary>
        /// <param name="adapter">NetworkInterface on the local machine with which this entry will be associated</param>
        /// <param name="address">IP Address of the entry</param>
        /// <param name="mac">Physical (MAC) address of the entry</param>
        /// <param name="entryType">Type of the entry</param>
        public ArpEntry(NetworkInterface adapter, IPAddress address, PhysicalAddress mac, ArpEntryType entryType)
        {
            m_adapter = adapter;
            m_data    = new byte[SIZE];

            this.IPAddress       = address;
            this.PhysicalAddress = mac;
            this.ArpEntryType    = entryType;
            this.AdapterIndex    = adapter.Index;
        }
    public static void Dispose()
    {
        InputManager.UnLoadDispatcher <InputNetworkConnectStatusEvent>();
        InputManager.UnLoadDispatcher <InputNetworkMessageEvent>();

        s_network.m_messageCallBack = null;
        s_network = null;

        ApplicationManager.s_OnApplicationUpdate -= Update;
    }
Example #27
0
 public void LogToWireshark(INetworkLog <INetworkInterface> reporter, INetworkInterface iface)
 {
     lock (innerLock)
     {
         if (IsConfiguredForMediumType(reporter))
         {
             AddInterface(reporter, iface);
         }
     }
 }
Example #28
0
 private void SendTransmittedFrame(IExternal reporter, INetworkInterface sender, byte[] buffer)
 {
     lock (innerLock)
     {
         if (observedInterfaces.ContainsKey(reporter) && observedInterfaces[reporter].Contains(sender))
         {
             wiresharkSender.SendReportedFrames(buffer);
         }
     }
 }
Example #29
0
        private void NetworkInterface_OnNewChallenge(INetworkInterface sender, byte[] challenge, string address)
        {
            m_challenge       = Utils.Numerics.Byte32ArrayToHexString(challenge);
            m_minerEthAddress = address;

            if (m_isCurrentChallengeStopSolving)
            {
                IsPause = false;
                m_isCurrentChallengeStopSolving = false;
            }
        }
Example #30
0
    /// <summary>

    /// <summary>
    /// 网络初始化
    /// </summary>
    /// <typeparam name="TProtocol">协议处理类</typeparam>
    /// <typeparam name="TSocket">Socket类</typeparam>
    /// <param name="protocolType">通讯协议</param>
    public void Init <TProtocol, TSocket>(ProtocolType protocolType = ProtocolType.Tcp) where TProtocol : INetworkInterface, new() where TSocket : SocketBase, new()
    {
        s_network = new TProtocol();
        s_network.m_socketService = new TSocket();

        Debug.Log("protocolType " + s_network.m_socketService.m_protocolType);

        s_network.m_socketService.m_protocolType = protocolType;

        NetInit();
    }
        public NetworkController(Discipline type)
        {
            switch (type)
            {
            case Discipline.Football:
                _network = new FootballNetwork();
                break;

            default: break;
            }
        }
Example #32
0
 public MqttNetworkClient(INetworkInterface network)
 {
     _network = network;
     _network.OnNetworkDisconnected += (sender, args) =>
     {
         var dis = OnNetworkDisconnected;
         if (dis != null)
         {
             dis(this, args);
         }
     };
 }
Example #33
0
 private static bool NetworkConnected(INetworkInterface networkInterface)
 {
     return string.Compare(networkInterface.CurrentIpAddress.ToString().Trim(), "0.0.0.0", StringComparison.OrdinalIgnoreCase) != 0;
 }
Example #34
0
 private static bool LANNetwork(INetworkInterface ni)
 {
     return ni.Speed == 10000000 || ni.Speed == 100000000;
 }
Example #35
0
 private static bool ActiveSyncNetwork(INetworkInterface ni)
 {
     return ni.Name.ToLower(System.Globalization.CultureInfo.CurrentCulture).StartsWith("usb", StringComparison.CurrentCulture);
 }
Example #36
0
 private static bool GPRSNetwork(INetworkInterface ni)
 {
     return ni.Name.ToLower(System.Globalization.CultureInfo.CurrentCulture).StartsWith("cellular line", StringComparison.CurrentCulture);
 }
Example #37
0
        private static INetworkInterface FindWirelessByExclusion(INetworkInterface[] interfaces)
        {
            foreach (var ni in interfaces)
            {
                if (LANNetwork(ni) || ActiveSyncNetwork(ni) || GPRSNetwork(ni))
                {
                    continue;
                }

                return ni;
            }

            return null;
        }
Example #38
0
        private static WirelessNetworkInterface FindWireless(INetworkInterface[] interfaces)
        {
            foreach (var ni in interfaces)
            {
                var wni = ni as WirelessNetworkInterface;
                if (wni != null)
                {
                    return wni;
                }
            }

            return null;
        }
Example #39
0
 private static bool BluetoothNetwork(INetworkInterface ni)
 {
     return ni.Name.ToLower(System.Globalization.CultureInfo.CurrentCulture).StartsWith("ss1vndis", StringComparison.CurrentCulture);
 }
Example #40
0
 public NetworkLink(INetworkInterface parent)
 {
     this.Parent = parent;
 }
Example #41
0
	public void Send(INetworkInterface i, Packet packet)
	{
		i.Send(packet.ToBytes());
	}
Example #42
0
 public StateMachineManager(INetworkInterface broker)
 {
     _broker = broker;
 }