Giter Site home page Giter Site logo

Could you specify some examples? about goupnp HOT 10 CLOSED

huin avatar huin commented on June 25, 2024
Could you specify some examples?

from goupnp.

Comments (10)

huin avatar huin commented on June 25, 2024 1

Yeah, the example is pretty limited, but hopefully it's a good starting point.

There's no clearly always-right answer for if there are multiple router devices on the network, it could be that a single router presents multiple devices and you could use any of them. So if there are multiple, experiment with printing the model name and IP address of each to work out what's going on.

If there are no devices, then either your router doesn't implement UPnP, or it's switched off. UPnP is often regarded as a potential security threat if left running, so it's not uncommon to want to switch it off.

Happy coding :)

from goupnp.

huin avatar huin commented on June 25, 2024

Did you see the examples in https://github.com/huin/goupnp/blob/master/example/example_test.go ?

As for examples that do something else, I'd have to refer to the UPnP docs for the specific device types.

from goupnp.

gekigek99 avatar gekigek99 commented on June 25, 2024

Yep I saw them... I just thought that having some sort of docs could help a lot

from goupnp.

huin avatar huin commented on June 25, 2024

Sorry for the delayed response. Could you be more specific about how the documentation could be improved/added? What problem you're trying to solve that's not being served?

https://pkg.go.dev/github.com/huin/goupnp contains the generated docs from this source, including the README.

One place that I know that the docs are lacking is that the packages under goupnp/dcps are pretty minimal (goupnp/dcps/internetgateway1 for example). Unfortunately that's source code generated from the XML UPnP specs, which don't themselves contain descriptive documentation.

Those generated docs themselves refer to the UPnP standards website (e.g for InternetGatewayDevice), which aren't the most readable docs, but I can't claim to have any better information or knowledge than those documents provide.

For context: I'm not a UPnP expert by any stretch, I just created this library for my own purposes once, ended up not needing it, but maintaining it from time to time as people have made contributions.

from goupnp.

gekigek99 avatar gekigek99 commented on June 25, 2024

Yea no worries! I just became interested in the UPnP protocol and wanted to learn how to use it (like, I still don't understand what's the difference between internetgateway1 and internetgateway2 ahahahah XD ) and your rep seems quite popular so I wanted to try it out...

What I meant for "example" is just some sort of "hello world" string sent from 1 PC to an other in LAN (or WAN) to demonstrate the communication between 2 machines. (like a client.go that when it's run on 2 PC in the same LAN, they automatically (or by just specifying the IP address) connect)

I know it's very basic and your code is capable of much more complex things but this could be a way for the thousands of people just like me that want to know something about UPnP connection... and only after that, study all the possible use cases.

whatever you decide to do, thanks for the consideration

p.s. I know that when you are into something everything seems easy, but for the eye of an outsider like me this is some really weird stuff XD

from goupnp.

huin avatar huin commented on June 25, 2024

Reading your example for wanting to send a string sent from one PC on a LAN to another on the same LAN, UPnP (and therefore goupnp) shouldn't be needed at all, you could do that using the facilities in the standard Go net library.

If you were wanting to talk between LANs without a server on the open Internet to relay between them (i.e peer-to-peer), you might need to use the internetgateway1 or internetgateway2 packages to open up port forwarding assignments on either (or both) LANs.

However, I would still refer back to the UPnP standards/specs/documentation. I would rather not repeat documentation that specifies what the UPnP stuff does (i.e the semantics of various method calls in this library).

Two things that might be worth amending the docs on for goupnp are:

  • Stronger emphasis on going to look at the UPnP standards docs. Maybe finding better links for them.
  • Explaining that the internetgateway1 and internetgateway2 packages implement clients for different versions of the standards, and that routers might implement only one or both of them - basically you might have to request client(s) from both packages and see what comes back.

What do you think of those changes?

TBH, this library is somewhat low level and could stand a lot of improvement. Most peoples' use cases would be better served by a higher level package which takes care of using this library to talk to the router, but presents a simpler interface to "just forward a port" and "get the external IP address".

from goupnp.

gekigek99 avatar gekigek99 commented on June 25, 2024

If you were wanting to talk between LANs without a server on the open Internet to relay between them (i.e peer-to-peer), you might need to use the internetgateway1 or internetgateway2 packages to open up port forwarding assignments on either (or both) LANs.

Oh yep i definitely meant a sort of peer to peer "hello world" example between 2 LANs...

However, I would still refer back to the UPnP standards/specs/documentation

my problem as a beginner is just that it's very difficult to have a simple working example for testing and learning step by step (I'm not asking you do write it for me, I just wanted to report a problem that I found... Probably this rep is too technical for me ahahah)

Stronger emphasis on going to look at the UPnP standards docs

yep this could be helpful, the ones linked are quite long and sooo in depth that it's difficult to have a glance at it

Explaining that the internetgateway1 and internetgateway2 packages

For me it would be very good, but I'm a beginner for this subject and maybe you want to make your rep for technicians...

TBH, this library is somewhat low level and could stand a lot of improvement. Most peoples' use cases would be better served by a higher level package which takes care of using this library to talk to the router, but presents a simpler interface to "just forward a port" and "get the external IP address".

yea you are probably right
do you know of any reps that have higher level functions?

from goupnp.

huin avatar huin commented on June 25, 2024

Sorry for the delay, this stuff tends to wait until the weekend when I have some free time. I've written up https://github.com/huin/goupnp/blob/master/GUIDE.md - let me know if that's helpful :)

from goupnp.

huin avatar huin commented on June 25, 2024

And as for a higher level library, I don't know of any offhand.

That said, looking for what packages import internetgateway2, there seem to be quite a few: https://pkg.go.dev/github.com/huin/goupnp/dcps/internetgateway2?tab=importedby

Quite a lot seem to be crypto-currency related things, and I certainly can't vouch for anyone else's code, but a lot of them do see to provide a nat package that handles port forwarding, and might contain interesting code to look at.

from goupnp.

gekigek99 avatar gekigek99 commented on June 25, 2024

ok thank you a lot!

even thought I'm am still unable to make it work (it says multiple or no services found), now it's clearer

it seems that the example just checks if there is some upnp service on the LAN and if there is none it exits while I am trying to start the listening for other clients online so that they can then communicate...

anyway thanks for the help!

That said, looking for what packages import internetgateway2, there seem to be quite a few: https://pkg.go.dev/github.com/huin/goupnp/dcps/internetgateway2?tab=importedby

thanks for the link I'll take a look :)

from goupnp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.