netdb.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. // Package netdb provides a Go interface for the protoent and servent
  2. // structures as defined in netdb.h
  3. //
  4. // A pure Go implementation is used by parsing /etc/protocols and
  5. // /etc/services
  6. //
  7. // All return values are pointers that point to the entries in the
  8. // original list of protocols and services. Manipulating the entries
  9. // would affect the entire program.
  10. package netdb // import "modernc.org/libc/honnef.co/go/netdb"
  11. // Modifications Copyright 2020 The Libc Authors. All rights reserved.
  12. // Use of this source code is governed by a BSD-style
  13. // license that can be found in the LICENSE file.
  14. import (
  15. "io/ioutil"
  16. "os"
  17. "strconv"
  18. "strings"
  19. )
  20. const (
  21. protocols = `
  22. # Internet (IP) protocols
  23. #
  24. # Updated from http://www.iana.org/assignments/protocol-numbers and other
  25. # sources.
  26. # New protocols will be added on request if they have been officially
  27. # assigned by IANA and are not historical.
  28. # If you need a huge list of used numbers please install the nmap package.
  29. ip 0 IP # internet protocol, pseudo protocol number
  30. hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
  31. icmp 1 ICMP # internet control message protocol
  32. igmp 2 IGMP # Internet Group Management
  33. ggp 3 GGP # gateway-gateway protocol
  34. ipencap 4 IP-ENCAP # IP encapsulated in IP (officially "IP")
  35. st 5 ST # ST datagram mode
  36. tcp 6 TCP # transmission control protocol
  37. egp 8 EGP # exterior gateway protocol
  38. igp 9 IGP # any private interior gateway (Cisco)
  39. pup 12 PUP # PARC universal packet protocol
  40. udp 17 UDP # user datagram protocol
  41. hmp 20 HMP # host monitoring protocol
  42. xns-idp 22 XNS-IDP # Xerox NS IDP
  43. rdp 27 RDP # "reliable datagram" protocol
  44. iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
  45. dccp 33 DCCP # Datagram Congestion Control Prot. [RFC4340]
  46. xtp 36 XTP # Xpress Transfer Protocol
  47. ddp 37 DDP # Datagram Delivery Protocol
  48. idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
  49. ipv6 41 IPv6 # Internet Protocol, version 6
  50. ipv6-route 43 IPv6-Route # Routing Header for IPv6
  51. ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
  52. idrp 45 IDRP # Inter-Domain Routing Protocol
  53. rsvp 46 RSVP # Reservation Protocol
  54. gre 47 GRE # General Routing Encapsulation
  55. esp 50 IPSEC-ESP # Encap Security Payload [RFC2406]
  56. ah 51 IPSEC-AH # Authentication Header [RFC2402]
  57. skip 57 SKIP # SKIP
  58. ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
  59. ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
  60. ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
  61. rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
  62. vmtp 81 VMTP # Versatile Message Transport
  63. eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
  64. ospf 89 OSPFIGP # Open Shortest Path First IGP
  65. ax.25 93 AX.25 # AX.25 frames
  66. ipip 94 IPIP # IP-within-IP Encapsulation Protocol
  67. etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
  68. encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
  69. # 99 # any private encryption scheme
  70. pim 103 PIM # Protocol Independent Multicast
  71. ipcomp 108 IPCOMP # IP Payload Compression Protocol
  72. vrrp 112 VRRP # Virtual Router Redundancy Protocol [RFC5798]
  73. l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
  74. isis 124 ISIS # IS-IS over IPv4
  75. sctp 132 SCTP # Stream Control Transmission Protocol
  76. fc 133 FC # Fibre Channel
  77. mobility-header 135 Mobility-Header # Mobility Support for IPv6 [RFC3775]
  78. udplite 136 UDPLite # UDP-Lite [RFC3828]
  79. mpls-in-ip 137 MPLS-in-IP # MPLS-in-IP [RFC4023]
  80. manet 138 # MANET Protocols [RFC5498]
  81. hip 139 HIP # Host Identity Protocol
  82. shim6 140 Shim6 # Shim6 Protocol [RFC5533]
  83. wesp 141 WESP # Wrapped Encapsulating Security Payload
  84. rohc 142 ROHC # Robust Header Compression
  85. `
  86. services = `
  87. # Network services, Internet style
  88. #
  89. # Note that it is presently the policy of IANA to assign a single well-known
  90. # port number for both TCP and UDP; hence, officially ports have two entries
  91. # even if the protocol doesn't support UDP operations.
  92. #
  93. # Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
  94. #
  95. # New ports will be added on request if they have been officially assigned
  96. # by IANA and used in the real-world or are needed by a debian package.
  97. # If you need a huge list of used numbers please install the nmap package.
  98. tcpmux 1/tcp # TCP port service multiplexer
  99. echo 7/tcp
  100. echo 7/udp
  101. discard 9/tcp sink null
  102. discard 9/udp sink null
  103. systat 11/tcp users
  104. daytime 13/tcp
  105. daytime 13/udp
  106. netstat 15/tcp
  107. qotd 17/tcp quote
  108. msp 18/tcp # message send protocol
  109. msp 18/udp
  110. chargen 19/tcp ttytst source
  111. chargen 19/udp ttytst source
  112. ftp-data 20/tcp
  113. ftp 21/tcp
  114. fsp 21/udp fspd
  115. ssh 22/tcp # SSH Remote Login Protocol
  116. telnet 23/tcp
  117. smtp 25/tcp mail
  118. time 37/tcp timserver
  119. time 37/udp timserver
  120. rlp 39/udp resource # resource location
  121. nameserver 42/tcp name # IEN 116
  122. whois 43/tcp nicname
  123. tacacs 49/tcp # Login Host Protocol (TACACS)
  124. tacacs 49/udp
  125. domain 53/tcp # Domain Name Server
  126. domain 53/udp
  127. bootps 67/udp
  128. bootpc 68/udp
  129. tftp 69/udp
  130. gopher 70/tcp # Internet Gopher
  131. finger 79/tcp
  132. http 80/tcp www # WorldWideWeb HTTP
  133. link 87/tcp ttylink
  134. kerberos 88/tcp kerberos5 krb5 kerberos-sec # Kerberos v5
  135. kerberos 88/udp kerberos5 krb5 kerberos-sec # Kerberos v5
  136. iso-tsap 102/tcp tsap # part of ISODE
  137. acr-nema 104/tcp dicom # Digital Imag. & Comm. 300
  138. pop3 110/tcp pop-3 # POP version 3
  139. sunrpc 111/tcp portmapper # RPC 4.0 portmapper
  140. sunrpc 111/udp portmapper
  141. auth 113/tcp authentication tap ident
  142. sftp 115/tcp
  143. nntp 119/tcp readnews untp # USENET News Transfer Protocol
  144. ntp 123/udp # Network Time Protocol
  145. epmap 135/tcp loc-srv # DCE endpoint resolution
  146. epmap 135/udp loc-srv
  147. netbios-ns 137/tcp # NETBIOS Name Service
  148. netbios-ns 137/udp
  149. netbios-dgm 138/tcp # NETBIOS Datagram Service
  150. netbios-dgm 138/udp
  151. netbios-ssn 139/tcp # NETBIOS session service
  152. netbios-ssn 139/udp
  153. imap2 143/tcp imap # Interim Mail Access P 2 and 4
  154. snmp 161/tcp # Simple Net Mgmt Protocol
  155. snmp 161/udp
  156. snmp-trap 162/tcp snmptrap # Traps for SNMP
  157. snmp-trap 162/udp snmptrap
  158. cmip-man 163/tcp # ISO mgmt over IP (CMOT)
  159. cmip-man 163/udp
  160. cmip-agent 164/tcp
  161. cmip-agent 164/udp
  162. mailq 174/tcp # Mailer transport queue for Zmailer
  163. mailq 174/udp
  164. xdmcp 177/tcp # X Display Mgr. Control Proto
  165. xdmcp 177/udp
  166. nextstep 178/tcp NeXTStep NextStep # NeXTStep window
  167. nextstep 178/udp NeXTStep NextStep # server
  168. bgp 179/tcp # Border Gateway Protocol
  169. irc 194/tcp # Internet Relay Chat
  170. irc 194/udp
  171. smux 199/tcp # SNMP Unix Multiplexer
  172. smux 199/udp
  173. at-rtmp 201/tcp # AppleTalk routing
  174. at-rtmp 201/udp
  175. at-nbp 202/tcp # AppleTalk name binding
  176. at-nbp 202/udp
  177. at-echo 204/tcp # AppleTalk echo
  178. at-echo 204/udp
  179. at-zis 206/tcp # AppleTalk zone information
  180. at-zis 206/udp
  181. qmtp 209/tcp # Quick Mail Transfer Protocol
  182. qmtp 209/udp
  183. z3950 210/tcp wais # NISO Z39.50 database
  184. z3950 210/udp wais
  185. ipx 213/tcp # IPX
  186. ipx 213/udp
  187. ptp-event 319/udp
  188. ptp-general 320/udp
  189. pawserv 345/tcp # Perf Analysis Workbench
  190. pawserv 345/udp
  191. zserv 346/tcp # Zebra server
  192. zserv 346/udp
  193. fatserv 347/tcp # Fatmen Server
  194. fatserv 347/udp
  195. rpc2portmap 369/tcp
  196. rpc2portmap 369/udp # Coda portmapper
  197. codaauth2 370/tcp
  198. codaauth2 370/udp # Coda authentication server
  199. clearcase 371/tcp Clearcase
  200. clearcase 371/udp Clearcase
  201. ulistserv 372/tcp # UNIX Listserv
  202. ulistserv 372/udp
  203. ldap 389/tcp # Lightweight Directory Access Protocol
  204. ldap 389/udp
  205. imsp 406/tcp # Interactive Mail Support Protocol
  206. imsp 406/udp
  207. svrloc 427/tcp # Server Location
  208. svrloc 427/udp
  209. https 443/tcp # http protocol over TLS/SSL
  210. snpp 444/tcp # Simple Network Paging Protocol
  211. snpp 444/udp
  212. microsoft-ds 445/tcp # Microsoft Naked CIFS
  213. microsoft-ds 445/udp
  214. kpasswd 464/tcp
  215. kpasswd 464/udp
  216. submissions 465/tcp ssmtp smtps urd # Submission over TLS [RFC8314]
  217. saft 487/tcp # Simple Asynchronous File Transfer
  218. saft 487/udp
  219. isakmp 500/tcp # IPsec - Internet Security Association
  220. isakmp 500/udp # and Key Management Protocol
  221. rtsp 554/tcp # Real Time Stream Control Protocol
  222. rtsp 554/udp
  223. nqs 607/tcp # Network Queuing system
  224. nqs 607/udp
  225. npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS
  226. npmp-local 610/udp dqs313_qmaster
  227. npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS
  228. npmp-gui 611/udp dqs313_execd
  229. hmmp-ind 612/tcp dqs313_intercell # HMMP Indication / DQS
  230. hmmp-ind 612/udp dqs313_intercell
  231. asf-rmcp 623/udp # ASF Remote Management and Control Protocol
  232. qmqp 628/tcp
  233. qmqp 628/udp
  234. ipp 631/tcp # Internet Printing Protocol
  235. ipp 631/udp
  236. #
  237. # UNIX specific services
  238. #
  239. exec 512/tcp
  240. biff 512/udp comsat
  241. login 513/tcp
  242. who 513/udp whod
  243. shell 514/tcp cmd # no passwords used
  244. syslog 514/udp
  245. printer 515/tcp spooler # line printer spooler
  246. talk 517/udp
  247. ntalk 518/udp
  248. route 520/udp router routed # RIP
  249. timed 525/udp timeserver
  250. tempo 526/tcp newdate
  251. courier 530/tcp rpc
  252. conference 531/tcp chat
  253. netnews 532/tcp readnews
  254. netwall 533/udp # for emergency broadcasts
  255. gdomap 538/tcp # GNUstep distributed objects
  256. gdomap 538/udp
  257. uucp 540/tcp uucpd # uucp daemon
  258. klogin 543/tcp # Kerberized 'rlogin' (v5)
  259. kshell 544/tcp krcmd # Kerberized 'rsh' (v5)
  260. dhcpv6-client 546/tcp
  261. dhcpv6-client 546/udp
  262. dhcpv6-server 547/tcp
  263. dhcpv6-server 547/udp
  264. afpovertcp 548/tcp # AFP over TCP
  265. afpovertcp 548/udp
  266. idfp 549/tcp
  267. idfp 549/udp
  268. remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem
  269. nntps 563/tcp snntp # NNTP over SSL
  270. submission 587/tcp # Submission [RFC4409]
  271. ldaps 636/tcp # LDAP over SSL
  272. ldaps 636/udp
  273. tinc 655/tcp # tinc control port
  274. tinc 655/udp
  275. silc 706/tcp
  276. silc 706/udp
  277. kerberos-adm 749/tcp # Kerberos 'kadmin' (v5)
  278. #
  279. webster 765/tcp # Network dictionary
  280. webster 765/udp
  281. domain-s 853/tcp # DNS over TLS [RFC7858]
  282. domain-s 853/udp # DNS over DTLS [RFC8094]
  283. rsync 873/tcp
  284. ftps-data 989/tcp # FTP over SSL (data)
  285. ftps 990/tcp
  286. telnets 992/tcp # Telnet over SSL
  287. imaps 993/tcp # IMAP over SSL
  288. pop3s 995/tcp # POP-3 over SSL
  289. #
  290. # From "ssigned Numbers":
  291. #
  292. #> The Registered Ports are not controlled by the IANA and on most systems
  293. #> can be used by ordinary user processes or programs executed by ordinary
  294. #> users.
  295. #
  296. #> Ports are used in the TCP [45,106] to name the ends of logical
  297. #> connections which carry long term conversations. For the purpose of
  298. #> providing services to unknown callers, a service contact port is
  299. #> defined. This list specifies the port used by the server process as its
  300. #> contact port. While the IANA can not control uses of these ports it
  301. #> does register or list uses of these ports as a convienence to the
  302. #> community.
  303. #
  304. socks 1080/tcp # socks proxy server
  305. socks 1080/udp
  306. proofd 1093/tcp
  307. proofd 1093/udp
  308. rootd 1094/tcp
  309. rootd 1094/udp
  310. openvpn 1194/tcp
  311. openvpn 1194/udp
  312. rmiregistry 1099/tcp # Java RMI Registry
  313. rmiregistry 1099/udp
  314. kazaa 1214/tcp
  315. kazaa 1214/udp
  316. nessus 1241/tcp # Nessus vulnerability
  317. nessus 1241/udp # assessment scanner
  318. lotusnote 1352/tcp lotusnotes # Lotus Note
  319. lotusnote 1352/udp lotusnotes
  320. ms-sql-s 1433/tcp # Microsoft SQL Server
  321. ms-sql-s 1433/udp
  322. ms-sql-m 1434/tcp # Microsoft SQL Monitor
  323. ms-sql-m 1434/udp
  324. ingreslock 1524/tcp
  325. ingreslock 1524/udp
  326. datametrics 1645/tcp old-radius
  327. datametrics 1645/udp old-radius
  328. sa-msg-port 1646/tcp old-radacct
  329. sa-msg-port 1646/udp old-radacct
  330. kermit 1649/tcp
  331. kermit 1649/udp
  332. groupwise 1677/tcp
  333. groupwise 1677/udp
  334. l2f 1701/tcp l2tp
  335. l2f 1701/udp l2tp
  336. radius 1812/tcp
  337. radius 1812/udp
  338. radius-acct 1813/tcp radacct # Radius Accounting
  339. radius-acct 1813/udp radacct
  340. msnp 1863/tcp # MSN Messenger
  341. msnp 1863/udp
  342. unix-status 1957/tcp # remstats unix-status server
  343. log-server 1958/tcp # remstats log server
  344. remoteping 1959/tcp # remstats remoteping server
  345. cisco-sccp 2000/tcp # Cisco SCCP
  346. cisco-sccp 2000/udp
  347. search 2010/tcp ndtp
  348. pipe-server 2010/tcp pipe_server
  349. nfs 2049/tcp # Network File System
  350. nfs 2049/udp # Network File System
  351. gnunet 2086/tcp
  352. gnunet 2086/udp
  353. rtcm-sc104 2101/tcp # RTCM SC-104 IANA 1/29/99
  354. rtcm-sc104 2101/udp
  355. gsigatekeeper 2119/tcp
  356. gsigatekeeper 2119/udp
  357. gris 2135/tcp # Grid Resource Information Server
  358. gris 2135/udp
  359. cvspserver 2401/tcp # CVS client/server operations
  360. cvspserver 2401/udp
  361. venus 2430/tcp # codacon port
  362. venus 2430/udp # Venus callback/wbc interface
  363. venus-se 2431/tcp # tcp side effects
  364. venus-se 2431/udp # udp sftp side effect
  365. codasrv 2432/tcp # not used
  366. codasrv 2432/udp # server port
  367. codasrv-se 2433/tcp # tcp side effects
  368. codasrv-se 2433/udp # udp sftp side effect
  369. mon 2583/tcp # MON traps
  370. mon 2583/udp
  371. dict 2628/tcp # Dictionary server
  372. dict 2628/udp
  373. f5-globalsite 2792/tcp
  374. f5-globalsite 2792/udp
  375. gsiftp 2811/tcp
  376. gsiftp 2811/udp
  377. gpsd 2947/tcp
  378. gpsd 2947/udp
  379. gds-db 3050/tcp gds_db # InterBase server
  380. gds-db 3050/udp gds_db
  381. icpv2 3130/tcp icp # Internet Cache Protocol
  382. icpv2 3130/udp icp
  383. isns 3205/tcp # iSNS Server Port
  384. isns 3205/udp # iSNS Server Port
  385. iscsi-target 3260/tcp
  386. mysql 3306/tcp
  387. mysql 3306/udp
  388. nut 3493/tcp # Network UPS Tools
  389. nut 3493/udp
  390. distcc 3632/tcp # distributed compiler
  391. distcc 3632/udp
  392. daap 3689/tcp # Digital Audio Access Protocol
  393. daap 3689/udp
  394. svn 3690/tcp subversion # Subversion protocol
  395. svn 3690/udp subversion
  396. suucp 4031/tcp # UUCP over SSL
  397. suucp 4031/udp
  398. sysrqd 4094/tcp # sysrq daemon
  399. sysrqd 4094/udp
  400. sieve 4190/tcp # ManageSieve Protocol
  401. epmd 4369/tcp # Erlang Port Mapper Daemon
  402. epmd 4369/udp
  403. remctl 4373/tcp # Remote Authenticated Command Service
  404. remctl 4373/udp
  405. f5-iquery 4353/tcp # F5 iQuery
  406. f5-iquery 4353/udp
  407. ipsec-nat-t 4500/udp # IPsec NAT-Traversal [RFC3947]
  408. iax 4569/tcp # Inter-Asterisk eXchange
  409. iax 4569/udp
  410. mtn 4691/tcp # monotone Netsync Protocol
  411. mtn 4691/udp
  412. radmin-port 4899/tcp # RAdmin Port
  413. radmin-port 4899/udp
  414. rfe 5002/udp # Radio Free Ethernet
  415. rfe 5002/tcp
  416. mmcc 5050/tcp # multimedia conference control tool (Yahoo IM)
  417. mmcc 5050/udp
  418. sip 5060/tcp # Session Initiation Protocol
  419. sip 5060/udp
  420. sip-tls 5061/tcp
  421. sip-tls 5061/udp
  422. aol 5190/tcp # AIM
  423. aol 5190/udp
  424. xmpp-client 5222/tcp jabber-client # Jabber Client Connection
  425. xmpp-client 5222/udp jabber-client
  426. xmpp-server 5269/tcp jabber-server # Jabber Server Connection
  427. xmpp-server 5269/udp jabber-server
  428. cfengine 5308/tcp
  429. cfengine 5308/udp
  430. mdns 5353/tcp # Multicast DNS
  431. mdns 5353/udp
  432. postgresql 5432/tcp postgres # PostgreSQL Database
  433. postgresql 5432/udp postgres
  434. freeciv 5556/tcp rptp # Freeciv gameplay
  435. freeciv 5556/udp
  436. amqps 5671/tcp # AMQP protocol over TLS/SSL
  437. amqp 5672/tcp
  438. amqp 5672/udp
  439. amqp 5672/sctp
  440. ggz 5688/tcp # GGZ Gaming Zone
  441. ggz 5688/udp
  442. x11 6000/tcp x11-0 # X Window System
  443. x11 6000/udp x11-0
  444. x11-1 6001/tcp
  445. x11-1 6001/udp
  446. x11-2 6002/tcp
  447. x11-2 6002/udp
  448. x11-3 6003/tcp
  449. x11-3 6003/udp
  450. x11-4 6004/tcp
  451. x11-4 6004/udp
  452. x11-5 6005/tcp
  453. x11-5 6005/udp
  454. x11-6 6006/tcp
  455. x11-6 6006/udp
  456. x11-7 6007/tcp
  457. x11-7 6007/udp
  458. gnutella-svc 6346/tcp # gnutella
  459. gnutella-svc 6346/udp
  460. gnutella-rtr 6347/tcp # gnutella
  461. gnutella-rtr 6347/udp
  462. sge-qmaster 6444/tcp sge_qmaster # Grid Engine Qmaster Service
  463. sge-qmaster 6444/udp sge_qmaster
  464. sge-execd 6445/tcp sge_execd # Grid Engine Execution Service
  465. sge-execd 6445/udp sge_execd
  466. mysql-proxy 6446/tcp # MySQL Proxy
  467. mysql-proxy 6446/udp
  468. babel 6696/udp # Babel Routing Protocol
  469. ircs-u 6697/tcp # Internet Relay Chat via TLS/SSL
  470. afs3-fileserver 7000/tcp bbs # file server itself
  471. afs3-fileserver 7000/udp bbs
  472. afs3-callback 7001/tcp # callbacks to cache managers
  473. afs3-callback 7001/udp
  474. afs3-prserver 7002/tcp # users & groups database
  475. afs3-prserver 7002/udp
  476. afs3-vlserver 7003/tcp # volume location database
  477. afs3-vlserver 7003/udp
  478. afs3-kaserver 7004/tcp # AFS/Kerberos authentication
  479. afs3-kaserver 7004/udp
  480. afs3-volser 7005/tcp # volume managment server
  481. afs3-volser 7005/udp
  482. afs3-errors 7006/tcp # error interpretation service
  483. afs3-errors 7006/udp
  484. afs3-bos 7007/tcp # basic overseer process
  485. afs3-bos 7007/udp
  486. afs3-update 7008/tcp # server-to-server updater
  487. afs3-update 7008/udp
  488. afs3-rmtsys 7009/tcp # remote cache manager service
  489. afs3-rmtsys 7009/udp
  490. font-service 7100/tcp xfs # X Font Service
  491. font-service 7100/udp xfs
  492. http-alt 8080/tcp webcache # WWW caching service
  493. http-alt 8080/udp
  494. puppet 8140/tcp # The Puppet master service
  495. bacula-dir 9101/tcp # Bacula Director
  496. bacula-dir 9101/udp
  497. bacula-fd 9102/tcp # Bacula File Daemon
  498. bacula-fd 9102/udp
  499. bacula-sd 9103/tcp # Bacula Storage Daemon
  500. bacula-sd 9103/udp
  501. xmms2 9667/tcp # Cross-platform Music Multiplexing System
  502. xmms2 9667/udp
  503. nbd 10809/tcp # Linux Network Block Device
  504. zabbix-agent 10050/tcp # Zabbix Agent
  505. zabbix-agent 10050/udp
  506. zabbix-trapper 10051/tcp # Zabbix Trapper
  507. zabbix-trapper 10051/udp
  508. amanda 10080/tcp # amanda backup services
  509. amanda 10080/udp
  510. dicom 11112/tcp
  511. hkp 11371/tcp # OpenPGP HTTP Keyserver
  512. hkp 11371/udp
  513. bprd 13720/tcp # VERITAS NetBackup
  514. bprd 13720/udp
  515. bpdbm 13721/tcp # VERITAS NetBackup
  516. bpdbm 13721/udp
  517. bpjava-msvc 13722/tcp # BP Java MSVC Protocol
  518. bpjava-msvc 13722/udp
  519. vnetd 13724/tcp # Veritas Network Utility
  520. vnetd 13724/udp
  521. bpcd 13782/tcp # VERITAS NetBackup
  522. bpcd 13782/udp
  523. vopied 13783/tcp # VERITAS NetBackup
  524. vopied 13783/udp
  525. db-lsp 17500/tcp # Dropbox LanSync Protocol
  526. dcap 22125/tcp # dCache Access Protocol
  527. gsidcap 22128/tcp # GSI dCache Access Protocol
  528. wnn6 22273/tcp # wnn6
  529. wnn6 22273/udp
  530. #
  531. # Datagram Delivery Protocol services
  532. #
  533. rtmp 1/ddp # Routing Table Maintenance Protocol
  534. nbp 2/ddp # Name Binding Protocol
  535. echo 4/ddp # AppleTalk Echo Protocol
  536. zip 6/ddp # Zone Information Protocol
  537. #=========================================================================
  538. # The remaining port numbers are not as allocated by IANA.
  539. #=========================================================================
  540. # Kerberos (Project Athena/MIT) services
  541. # Note that these are for Kerberos v4, and are unofficial. Sites running
  542. # v4 should uncomment these and comment out the v5 entries above.
  543. #
  544. kerberos4 750/udp kerberos-iv kdc # Kerberos (server)
  545. kerberos4 750/tcp kerberos-iv kdc
  546. kerberos-master 751/udp kerberos_master # Kerberos authentication
  547. kerberos-master 751/tcp
  548. passwd-server 752/udp passwd_server # Kerberos passwd server
  549. krb-prop 754/tcp krb_prop krb5_prop hprop # Kerberos slave propagation
  550. krbupdate 760/tcp kreg # Kerberos registration
  551. swat 901/tcp # swat
  552. kpop 1109/tcp # Pop with Kerberos
  553. knetd 2053/tcp # Kerberos de-multiplexor
  554. zephyr-srv 2102/udp # Zephyr server
  555. zephyr-clt 2103/udp # Zephyr serv-hm connection
  556. zephyr-hm 2104/udp # Zephyr hostmanager
  557. eklogin 2105/tcp # Kerberos encrypted rlogin
  558. # Hmmm. Are we using Kv4 or Kv5 now? Worrying.
  559. # The following is probably Kerberos v5 --- ajt@debian.org (11/02/2000)
  560. kx 2111/tcp # X over Kerberos
  561. iprop 2121/tcp # incremental propagation
  562. #
  563. # Unofficial but necessary (for NetBSD) services
  564. #
  565. supfilesrv 871/tcp # SUP server
  566. supfiledbg 1127/tcp # SUP debugging
  567. #
  568. # Services added for the Debian GNU/Linux distribution
  569. #
  570. poppassd 106/tcp # Eudora
  571. poppassd 106/udp
  572. moira-db 775/tcp moira_db # Moira database
  573. moira-update 777/tcp moira_update # Moira update protocol
  574. moira-ureg 779/udp moira_ureg # Moira user registration
  575. spamd 783/tcp # spamassassin daemon
  576. omirr 808/tcp omirrd # online mirror
  577. omirr 808/udp omirrd
  578. customs 1001/tcp # pmake customs server
  579. customs 1001/udp
  580. skkserv 1178/tcp # skk jisho server port
  581. predict 1210/udp # predict -- satellite tracking
  582. rmtcfg 1236/tcp # Gracilis Packeten remote config server
  583. wipld 1300/tcp # Wipl network monitor
  584. xtel 1313/tcp # french minitel
  585. xtelw 1314/tcp # french minitel
  586. support 1529/tcp # GNATS
  587. cfinger 2003/tcp # GNU Finger
  588. frox 2121/tcp # frox: caching ftp proxy
  589. ninstall 2150/tcp # ninstall service
  590. ninstall 2150/udp
  591. zebrasrv 2600/tcp # zebra service
  592. zebra 2601/tcp # zebra vty
  593. ripd 2602/tcp # ripd vty (zebra)
  594. ripngd 2603/tcp # ripngd vty (zebra)
  595. ospfd 2604/tcp # ospfd vty (zebra)
  596. bgpd 2605/tcp # bgpd vty (zebra)
  597. ospf6d 2606/tcp # ospf6d vty (zebra)
  598. ospfapi 2607/tcp # OSPF-API
  599. isisd 2608/tcp # ISISd vty (zebra)
  600. afbackup 2988/tcp # Afbackup system
  601. afbackup 2988/udp
  602. afmbackup 2989/tcp # Afmbackup system
  603. afmbackup 2989/udp
  604. xtell 4224/tcp # xtell server
  605. fax 4557/tcp # FAX transmission service (old)
  606. hylafax 4559/tcp # HylaFAX client-server protocol (new)
  607. distmp3 4600/tcp # distmp3host daemon
  608. munin 4949/tcp lrrd # Munin
  609. enbd-cstatd 5051/tcp # ENBD client statd
  610. enbd-sstatd 5052/tcp # ENBD server statd
  611. pcrd 5151/tcp # PCR-1000 Daemon
  612. noclog 5354/tcp # noclogd with TCP (nocol)
  613. noclog 5354/udp # noclogd with UDP (nocol)
  614. hostmon 5355/tcp # hostmon uses TCP (nocol)
  615. hostmon 5355/udp # hostmon uses UDP (nocol)
  616. rplay 5555/udp # RPlay audio service
  617. nrpe 5666/tcp # Nagios Remote Plugin Executor
  618. nsca 5667/tcp # Nagios Agent - NSCA
  619. mrtd 5674/tcp # MRT Routing Daemon
  620. bgpsim 5675/tcp # MRT Routing Simulator
  621. canna 5680/tcp # cannaserver
  622. syslog-tls 6514/tcp # Syslog over TLS [RFC5425]
  623. sane-port 6566/tcp sane saned # SANE network scanner daemon
  624. ircd 6667/tcp # Internet Relay Chat
  625. zope-ftp 8021/tcp # zope management by ftp
  626. tproxy 8081/tcp # Transparent Proxy
  627. omniorb 8088/tcp # OmniORB
  628. omniorb 8088/udp
  629. clc-build-daemon 8990/tcp # Common lisp build daemon
  630. xinetd 9098/tcp
  631. mandelspawn 9359/udp mandelbrot # network mandelbrot
  632. git 9418/tcp # Git Version Control System
  633. zope 9673/tcp # zope server
  634. webmin 10000/tcp
  635. kamanda 10081/tcp # amanda backup services (Kerberos)
  636. kamanda 10081/udp
  637. amandaidx 10082/tcp # amanda backup services
  638. amidxtape 10083/tcp # amanda backup services
  639. smsqp 11201/tcp # Alamin SMS gateway
  640. smsqp 11201/udp
  641. xpilot 15345/tcp # XPilot Contact Port
  642. xpilot 15345/udp
  643. sgi-cmsd 17001/udp # Cluster membership services daemon
  644. sgi-crsd 17002/udp
  645. sgi-gcd 17003/udp # SGI Group membership daemon
  646. sgi-cad 17004/tcp # Cluster Admin daemon
  647. isdnlog 20011/tcp # isdn logging system
  648. isdnlog 20011/udp
  649. vboxd 20012/tcp # voice box system
  650. vboxd 20012/udp
  651. binkp 24554/tcp # binkp fidonet protocol
  652. asp 27374/tcp # Address Search Protocol
  653. asp 27374/udp
  654. csync2 30865/tcp # cluster synchronization tool
  655. dircproxy 57000/tcp # Detachable IRC Proxy
  656. tfido 60177/tcp # fidonet EMSI over telnet
  657. fido 60179/tcp # fidonet EMSI over TCP
  658. # Local services
  659. `
  660. )
  661. type Protoent struct {
  662. Name string
  663. Aliases []string
  664. Number int
  665. }
  666. type Servent struct {
  667. Name string
  668. Aliases []string
  669. Port int
  670. Protocol *Protoent
  671. }
  672. // These variables get populated from /etc/protocols and /etc/services
  673. // respectively.
  674. var (
  675. Protocols []*Protoent
  676. Services []*Servent
  677. )
  678. func init() {
  679. protoMap := make(map[string]*Protoent)
  680. // Load protocols
  681. data, err := ioutil.ReadFile("/etc/protocols")
  682. if err != nil {
  683. if !os.IsNotExist(err) {
  684. panic(err)
  685. }
  686. data = []byte(protocols)
  687. }
  688. for _, line := range strings.Split(string(data), "\n") {
  689. line = strings.TrimSpace(line)
  690. split := strings.SplitN(line, "#", 2)
  691. fields := strings.Fields(split[0])
  692. if len(fields) < 2 {
  693. continue
  694. }
  695. num, err := strconv.ParseInt(fields[1], 10, 32)
  696. if err != nil {
  697. // If we find lines that don't match the expected format we skip over them.
  698. // The expected format is <protocol> <number> <aliases> ...
  699. // As we're using strings.Fields for splitting the line, failures can happen if the protocol field contains white spaces.
  700. continue
  701. }
  702. protoent := &Protoent{
  703. Name: fields[0],
  704. Aliases: fields[2:],
  705. Number: int(num),
  706. }
  707. Protocols = append(Protocols, protoent)
  708. protoMap[fields[0]] = protoent
  709. }
  710. // Load services
  711. data, err = ioutil.ReadFile("/etc/services")
  712. if err != nil {
  713. if !os.IsNotExist(err) {
  714. panic(err)
  715. }
  716. data = []byte(services)
  717. }
  718. for _, line := range strings.Split(string(data), "\n") {
  719. line = strings.TrimSpace(line)
  720. split := strings.SplitN(line, "#", 2)
  721. fields := strings.Fields(split[0])
  722. if len(fields) < 2 {
  723. continue
  724. }
  725. // https://gitlab.com/cznic/libc/-/issues/25
  726. if strings.Index(fields[1], "/") < 0 {
  727. continue
  728. }
  729. name := fields[0]
  730. portproto := strings.SplitN(fields[1], "/", 2)
  731. port, err := strconv.ParseInt(portproto[0], 10, 32)
  732. if err != nil {
  733. // If we find lines that don't match the expected format we skip over them.
  734. // The expected format is <service-name> <port>/<protocol> [aliases ...]
  735. // As we're using strings.Fields for splitting the line, failures can happen if the service name field contains white spaces.
  736. continue
  737. }
  738. proto := portproto[1]
  739. aliases := fields[2:]
  740. Services = append(Services, &Servent{
  741. Name: name,
  742. Aliases: aliases,
  743. Port: int(port),
  744. Protocol: protoMap[proto],
  745. })
  746. }
  747. }
  748. // Equal checks if two Protoents are the same, which is the case if
  749. // their protocol numbers are identical or when both Protoents are
  750. // nil.
  751. func (this *Protoent) Equal(other *Protoent) bool {
  752. if this == nil && other == nil {
  753. return true
  754. }
  755. if this == nil || other == nil {
  756. return false
  757. }
  758. return this.Number == other.Number
  759. }
  760. // Equal checks if two Servents are the same, which is the case if
  761. // their port numbers and protocols are identical or when both
  762. // Servents are nil.
  763. func (this *Servent) Equal(other *Servent) bool {
  764. if this == nil && other == nil {
  765. return true
  766. }
  767. if this == nil || other == nil {
  768. return false
  769. }
  770. return this.Port == other.Port &&
  771. this.Protocol.Equal(other.Protocol)
  772. }
  773. // GetProtoByNumber returns the Protoent for a given protocol number.
  774. func GetProtoByNumber(num int) (protoent *Protoent) {
  775. for _, protoent := range Protocols {
  776. if protoent.Number == num {
  777. return protoent
  778. }
  779. }
  780. return nil
  781. }
  782. // GetProtoByName returns the Protoent whose name or any of its
  783. // aliases matches the argument.
  784. func GetProtoByName(name string) (protoent *Protoent) {
  785. for _, protoent := range Protocols {
  786. if protoent.Name == name {
  787. return protoent
  788. }
  789. for _, alias := range protoent.Aliases {
  790. if alias == name {
  791. return protoent
  792. }
  793. }
  794. }
  795. return nil
  796. }
  797. // GetServByName returns the Servent for a given service name or alias
  798. // and protocol. If the protocol is nil, the first service matching
  799. // the service name is returned.
  800. func GetServByName(name string, protocol *Protoent) (servent *Servent) {
  801. for _, servent := range Services {
  802. if !servent.Protocol.Equal(protocol) {
  803. continue
  804. }
  805. if servent.Name == name {
  806. return servent
  807. }
  808. for _, alias := range servent.Aliases {
  809. if alias == name {
  810. return servent
  811. }
  812. }
  813. }
  814. return nil
  815. }
  816. // GetServByPort returns the Servent for a given port number and
  817. // protocol. If the protocol is nil, the first service matching the
  818. // port number is returned.
  819. func GetServByPort(port int, protocol *Protoent) *Servent {
  820. for _, servent := range Services {
  821. if servent.Port == port && servent.Protocol.Equal(protocol) {
  822. return servent
  823. }
  824. }
  825. return nil
  826. }