natType

package module
v0.0.0-...-18d4216 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 10 Imported by: 1

README

nat-type-identifier-go

A Go based implementation of Network Address Transalation (NAT) type identifier based on nat-type-identifier (written by Hutchison-Technologies) and PyStun (written by gaohawk). This repository follows follows RFC 3489 https://www.ietf.org/rfc/rfc3489.txt

The return of execution will return the NAT type in use by the system running the program, the returned type will be one of the following:

- Blocked
- Open Internet
- Full Cone
- Symmetric UDP Firewall
- Restric NAT
- Restric Port NAT
- Symmetric NAT

Features

To ensure the most reliable result, the program executes a number of tests which each determine the NAT type before a mode is selected from the list of results based on the most probable type. This is because issues might occur where occasional UDP packets fail to deliver.

Usage

import (
    natType "github.com/Curtis-Milo/nat-type-identifier-go"
)

func main() {
	natType.GetDeterminedNatType(true, 10, "stun.sipgate.net")
}

Installation

go get github.com/Curtis-Milo/nat-type-identifier-go

Sponsored by

This project was sponsored by www.menlolab.com

License

Copyright (c) Hutchison Technologies Ltd. MIT Licensed

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const (
	MappedAddress   = "0001"
	ResponseAddress = "0002"
	ChangeRequest   = "0003"
	SourceAddress   = "0004"
	ChangedAddress  = "0005"
)
View Source
const (
	BLOCKED                = "Blocked"
	OPEN_INTERNET          = "Open Internet"
	FULL_CONE              = "Full Cone"
	SYMMETRIC_UDP_FIREWALL = "Symmetric UDP Firewall"
	RESTRICTED_NAT         = "Restric NAT"
	RESTRICTED_PORT_NAT    = "Restric Port NAT"
	SYMMETRIC_NAT          = "Symmetric NAT"
	ERROR                  = "Error"
)

NAT Types

View Source
const (
	EXT_IP       = "ExternalIP"
	EXT_PORT     = "ExternalPort"
	SRC_IP       = "SourceIP"
	SRC_PORT     = "SourcePort"
	CHANGED_IP   = "ChangedIP"
	CHANGED_PORT = "ChangedPort"
	RESP         = "Resp"
)

Response Attributes

View Source
const (
	CHANGE_ADDR_ERR = "Error occurred during Test on Changed IP and Port"
	LOGS_ACTIVE     = "LOGS-ACTIVE"
	SOCKET_TIMEOUT  = 3
	MAX_RETRIES     = 3
)
View Source
const (
	BindRequestMsg = "0001"
)

Variables

This section is empty.

Functions

func GetDeterminedNatType

func GetDeterminedNatType(logging bool, sampleCount int, stunHost string) (string, error)

Types

type StunResp

type StunResp struct {
	Resp         bool
	ExternalIP   string
	ExternalPort int
	SourceIP     string
	SourcePort   int
	ChangedIP    string
	ChangedPort  int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL