sshnet / sshnet/SSH.NET

Cannot listen to port on ALL interfaces "0.0.0.0"

Aperta
#525 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
4.4k
Fork
993
Merge medio
9g 21h
PR unite (30g)
1

Descrizione

I found that you cannot do a ForwardedPortLocal/Remote if the bound host is set to "0.0.0.0" or IPAddress.Any.ToString().
The .NET will throw an exception.

I think your problem is in the ForwardedPortLocal:InternalStart() method. I think when you create the IPEndPoint you should do:

IPEndPoint ipEndPoint;
if (this.BoundHost == IPAddress.Any.ToString()) // Or however you want to compare
ipEndPoint = new IPEndPoint(IPAddress.Any, (int) this.BoundPort);
else
ipEndPoint = new IPEndPoint(DnsAbstraction.GetHostAddresses(this.BoundHost)[0], (int) this.BoundPort);

Similarly, the constructor, ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port)
creates the IPAddress of the bound host exaclty the same way, by calling Dns.GetHostAdresses().

I am not sure if you did this on purpose to try to NOT support IPAddress.Any, however, it is clear there are cases when this is needed, and in fact other libraries (SecureBlackBox) support it.

I see you allow boundHost to be string.Empty, but shouldn't then you be doing the conversion to IPAdress.Any directly?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con ForwardedPortLocal:InternalStart() e il costruttore ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port), quindi esamina come DnsAbstraction risolve l'host associato prima di creare un IPEndPoint. La modifica è completata quando il forwarding accetta "0.0.0.0" e un host associato vuoto senza l'eccezione .NET segnalata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
networking
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.