Net::U...ateway(3pm)
π Net::UPnP::GW::Gateway π
okay bestie, so this is a page from the User Contributed Perl Documentation for the module Net::UPnP::GW::Gateway (that's the 3pm situation β a Perl module manual, iykyk). It's a Perl extension for UPnP, and it's giving gateway energy, and we're gonna go through it together, no cap. π¦
β¨ NAME β¨
Net::UPnP::GW::Gateway β Perl extension for UPnP. that's it, that's the name, she's simple and she's iconic. π
π SYNOPSIS π
here's the whole vibe, copied exactly so you can steal it:
use Net::UPnP::ControlPoint;
use Net::UPnP::GW::Gateway;
my $obj = Net::UPnP::ControlPoint->new();
@dev_list = ();
while (@dev_list <= 0 || $retry_cnt > 5) {
# @dev_list = $obj->search(st =>'urn:schemas-upnp-org:device:InternetGatewayDevice:1', mx => 10);
@dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
$retry_cnt++;
}
$devNum= 0;
foreach $dev (@dev_list) {
my $device_type = $dev->getdevicetype();
if ($device_type ne 'urn:schemas-upnp-org:device:InternetGatewayDevice:1') {
next;
}
print "[$devNum] : " . $dev->getfriendlyname() . "\n";
unless ($dev->getservicebyname('urn:schemas-upnp-org:service:WANIPConnection:1')) {
next;
}
my $gwdev = Net::UPnP::GW::Gateway->new();
$gwdev->setdevice($dev);
print "\tExternalIPAddress = " . $gwdev->getexternalipaddress() . "\n";
print "\tPortMappingNumberOfEntries = " . $gwdev->getportmappingnumberofentries() . "\n";
@port_mapping = $gwdev->getportmappingentries();
$port_num = 0;
foreach $port_entry (@port_mapping) {
$port_map_name = $port_entry->{'NewPortMappingDescription'};
if (length($port_map_name) <= 0) {
$port_map_name = "(No name)";
}
print " [$port_num] : $port_map_name\n";
foreach $name ( keys %{$port_entry} ) {
print " $name = $port_entry->{$name}\n";
}
$port_num++;
}
}
likeβ¦ she's thorough. she searches, she loops, she prints. main character behavior fr fr. π₯
π DESCRIPTION π
The package is a extension UPnP/GW. yep, that's the whole description, short and sweet, a little lowercase moment, we respect it. π
πΈ METHODS πΈ
new β create new Net::UPnP::GW::Gateway.
$mservier = Net::UPnP::GW::Gateway();
Creates a new object. Read perldoc perlboot if you don't understand that. (not me telling you to go read the docs, but like, respectfully, go read the docs bestie π)
The new object is not associated with any UPnP devices. Please use setdevice() to set the device. so she's brand new and unbothered, no device attached yet, you gotta introduce her. β¨
setdevice β set a UPnP devices
$gw->setdevice($dev);
Set a device to the object. matchmaker behavior, honestly. π«Ά
getexternalipaddress β External IP address
$gw->getexternalipaddress();
Get the external IP address. that's your outside-the-house address, the one the internet knows you by. π
getportmappingnumberofentries β PortMappingNumberOfEntries
$gw->getportmappingnumberofentries();
Get the number of the port mapping entries. just a lil count, a census of your mappings. π
getportmappingentries β PortMappingEntry
$gw->getportmappingentries();
Get the port mapping entries. all of them. the whole lineup. π
addportmapping β add new port mapping.
$result = gw->addportmapping(
NewRemoteHost # '',
NewExternalPort # '',
NewProtocol # '',
NewInternalPort # '',
NewInternalClient # '',
NewEnabled #1,
NewPortMappingDescription # '',
NewLeaseDuration # 0);
Add a new specified port mapping. eight whole arguments, she does NOT do things by halves. notice NewEnabled defaults to 1 and NewLeaseDuration defaults to 0, the rest are empty strings. periodt. β
deleteportmapping β delete a port mapping.
$result = gw->deleteportmapping(
NewRemoteHost # '',
NewExternalPort # '',
NewProtocol # '');
Delete the specified port mapping. three arguments only, she's efficient when she wants to be. bye bye mapping π¦
gettotalbytesreceived β Total received bytes.
$gw->gettotalbytesreceived();
Get the total received bytes. the big number. the receipts, literally. π
π§ AUTHOR π§
Satoshi Konno skonno@cybergarage.org
CyberGarage http://www.cybergarage.org
π COPYRIGHT AND LICENSE π
Copyright (C) 2005 by Satoshi Konno
It may be used, redistributed, and/or modified under the terms of BSD License.
so basically: use it, share it, remix it β just respect the BSD License terms, bestie. that's the whole deal. π«Ά
and that's the page!! this whole thing is from perl v5.36.0, dated 2022-12-06, and it's the Net::UPnP::GW::Gateway(3pm) manual from the User Contributed Perl Documentation. slay, go map some ports responsibly πβ¨π
π¦ where this page comes from
- debian bookworm: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- debian trixie: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu noble: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu resolute: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu stonking: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms