You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
Hello.
I have an huawei HA35 router.
It's a hybrid thing. It have a DSL and a LTE connection that it bonding together to one connection.
But the thing is that this code
`
namespace Auto_open_UPnP
{
class Program
{
public static void Main(string[] args)
{
Open.Nat.NatDiscoverer.TraceSource.Switch.Level = SourceLevels.Verbose;
Open.Nat.NatDiscoverer.TraceSource.Listeners.Add(new ColorConsoleTraceListener());
Test().Wait();
var endPoint = new IPEndPoint(IPAddress.Any, 1602);
var socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
socket.Bind(endPoint);
socket.Listen(4);
Console.ReadKey();
socket.Close();
}
private async static Task Test()
{
var nat = new Open.Nat.NatDiscoverer();
var cts = new CancellationTokenSource(5000);
var device = await nat.DiscoverDeviceAsync(Open.Nat.PortMapper.Upnp, cts);
foreach (var mapping in await device.GetAllMappingsAsync())
{
if (mapping.Description.Contains("RDP"))
{
Console.WriteLine("Deleting {0}", mapping);
await device.DeletePortMapAsync(mapping);
Console.WriteLine("Port mapping Deleted");
}
if (mapping.Description.Contains("uTorrent"))
{
Console.WriteLine("Deleting {0}", mapping);
await device.DeletePortMapAsync(mapping);
Console.WriteLine("Port mapping Deleted");
}
}
var sb = new StringBuilder();
var ip = await device.GetExternalIPAsync();
sb.AppendFormat("\nYour IP: {0}", ip);
await device.CreatePortMapAsync(new Open.Nat.Mapping(Open.Nat.Protocol.Udp, 3389, 3389, "RDP UDP"));
await device.CreatePortMapAsync(new Open.Nat.Mapping(Open.Nat.Protocol.Tcp, 3389, 3389, "RDP TCP"));
sb.AppendFormat("\n+------+----------------------+-------------------------+-------------+--------+");
sb.AppendFormat("\n| PROT | PUBLIC (Reacheable) | PRIVATE (Your computer) | Descriptopn | |");
sb.AppendFormat("\n+------+-------------+--------+-------------------------+------+------+--------+");
sb.AppendFormat("\n| | IP Address | Port | IP Address | Port | | Expires |");
sb.AppendFormat("\n+------+-------------+--------+----------------+--------+------+---------------+");
foreach (var mapping in await device.GetAllMappingsAsync())
{
sb.AppendFormat("\n| {5} |{0}| {1} | {2} |{3} | {4} |{6}|",
ip, mapping.PublicPort, mapping.PrivateIP, mapping.PrivatePort, mapping.Description, mapping.Protocol == Open.Nat.Protocol.Udp ? "TCP" : "UDP", mapping.Expiration.ToLocalTime());
}
sb.AppendFormat("\n+------+-------------+--------+----------------+--------+------+---------------+");
sb.AppendFormat("\n[Done]");
Console.WriteLine(sb.ToString());
}
}
}
`
The application breaks already at "Test().Wait();" but if i use my regular xDSL router it works.
I don't know what's the reson for the break but if you need more info to help me fix this just tell me what and how and then i will do my best to give you the info.
The text was updated successfully, but these errors were encountered:
I'm not seeing what the issue is here, but in my case I added a Thread.Sleep(2000) call on Form_Closing, which properly waits for the entry to delete from router table and close application. If you don't wait on it, it won't have time to remove ports (in my case, on a brand new Aeris DOCSIS 3.1 modem).
Just some insight.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello.
I have an huawei HA35 router.
It's a hybrid thing. It have a DSL and a LTE connection that it bonding together to one connection.
But the thing is that this code
`
namespace Auto_open_UPnP
{
class Program
{
public static void Main(string[] args)
{
Open.Nat.NatDiscoverer.TraceSource.Switch.Level = SourceLevels.Verbose;
Open.Nat.NatDiscoverer.TraceSource.Listeners.Add(new ColorConsoleTraceListener());
Test().Wait();
var endPoint = new IPEndPoint(IPAddress.Any, 1602);
var socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
socket.Bind(endPoint);
socket.Listen(4);
}
}
`
The application breaks already at "Test().Wait();" but if i use my regular xDSL router it works.
I don't know what's the reson for the break but if you need more info to help me fix this just tell me what and how and then i will do my best to give you the info.
The text was updated successfully, but these errors were encountered: