All Projects → netinternet → remoteaddr

netinternet / remoteaddr

Licence: MIT license
Go http real ip header parser

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to remoteaddr

captcp
A open source program for TCP analysis of PCAP files
Stars: ✭ 110 (+511.11%)
Mutual labels:  ip
alfred-ip-address-workflow
Alfred 5 workflow for getting your local and external IP addresses.
Stars: ✭ 163 (+805.56%)
Mutual labels:  ip
telemirror
Telegram forwarder from channels via Telegram Client API (telethon)
Stars: ✭ 66 (+266.67%)
Mutual labels:  forwarder
ipwatch
This program gets your external, & internal, IP addresses, checks them against your "saved" IP addresses and, if a difference is found, emails you the new IP(s). This is useful for servers at residential locations whose IP address may change periodically due to actions by the ISP.
Stars: ✭ 38 (+111.11%)
Mutual labels:  ip
IP-Monitor
CSDN博客
Stars: ✭ 32 (+77.78%)
Mutual labels:  ip
PortForwarder
A small program to forward TCP traffic with QoS options
Stars: ✭ 30 (+66.67%)
Mutual labels:  forwarder
SWELF
Simple Windows Event Log Forwarder (SWELF). Its easy to use/simply works Log Forwarder and EVTX Parser. Almost in full release here at https://github.com/ceramicskate0/SWELF/releases/latest.
Stars: ✭ 23 (+27.78%)
Mutual labels:  forwarder
Python
Python Powered Repository
Stars: ✭ 17 (-5.56%)
Mutual labels:  ip
geoip-native-lite
Super-fast IP to country lookups for node.js with minimal RAM usage.
Stars: ✭ 15 (-16.67%)
Mutual labels:  ip
tor-ip-changer
request new identity every X seconds interval using TOR client
Stars: ✭ 233 (+1194.44%)
Mutual labels:  ip
NetworkAdapterSelector
A simple solution to let you force bind a program to a specific network adapter
Stars: ✭ 168 (+833.33%)
Mutual labels:  ip
vector
A high-performance observability data pipeline.
Stars: ✭ 12,138 (+67333.33%)
Mutual labels:  forwarder
HexBot
A Relatively Simply Awesome Discord bot with Music, Games, Comics, Memes and other cool features. This bot is made in Python 3.8 using discord.py
Stars: ✭ 109 (+505.56%)
Mutual labels:  ip
echoIP
显示客户端IP的详细信息
Stars: ✭ 63 (+250%)
Mutual labels:  ip
china-ip-list
每小时更新中国IP范围列表,Update Mainland China ip‘s list in everyhour
Stars: ✭ 40 (+122.22%)
Mutual labels:  ip
is-cidr
Check if a string is an IP address in CIDR notation
Stars: ✭ 27 (+50%)
Mutual labels:  ip
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (+283.33%)
Mutual labels:  ip
sledgehammer
🔨 📶 WiFi-Jammer/DoS toolset
Stars: ✭ 34 (+88.89%)
Mutual labels:  ip
server-ip-addresses
Daily updated list of IP addresses / CIDR blocks used by data centers, cloud service providers, servers, etc.
Stars: ✭ 74 (+311.11%)
Mutual labels:  ip
HttpProxy
JAVA实现的IP代理池,支持HTTP与HTTPS两种方式
Stars: ✭ 37 (+105.56%)
Mutual labels:  ip

remoteaddr

Go http real ip header parser module

A forwarders such as a reverse proxy or Cloudflare find the real IP address from the requests made to the http server behind it. Local IP addresses and CloudFlare ip addresses are defined by default within the module. It is possible to define more forwarder IP addresses.

In Turkey, it is obligatory to keep the port information of IP addresses shared with cgnat by the law no 5651. For this reason, dst port information is also given along with the IP addresses. If the IP address is behind a proxy, the dst port information is returned as -1.

Usage

go get -u github.com/netinternet/remoteaddr
// remoteaddr.Parse().IP(*http.Request) return to string IPv4 or IPv6 address

Example

Run a simple web server and get the real IP address to string format

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/netinternet/remoteaddr"
)

func root(w http.ResponseWriter, r *http.Request) {
	ip, port := remoteaddr.Parse().IP(r)
	fmt.Fprintf(w, "Your IP address is "+ip+" and dst port "+port)
}

func main() {
	http.HandleFunc("/", root)
	log.Fatal(http.ListenAndServe(":8081", nil))
}

Example 2 (Nginx or another web service forwarder address)

AddForwarders([]string{"8.8.8.0/24"}) = Add a new multiple forwarder prefixes

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/netinternet/remoteaddr"
)

func root(w http.ResponseWriter, r *http.Request) {
	ip, port := remoteaddr.Parse().AddForwarders([]string{"8.8.8.0/24"}).IP(r)
	fmt.Fprintf(w, "Your IP address is "+ip+" and dst port "+port)
}

func main() {
	http.HandleFunc("/", root)
	log.Fatal(http.ListenAndServe(":8081", nil))
}

Example 3 (Add an alternative header for real IP address)

AddHeaders([]string{"True-Client-IP"}) = Add a new multiple real ip headers

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/netinternet/remoteaddr"
)

func root(w http.ResponseWriter, r *http.Request) {
	ip, port := remoteaddr.Parse().AddHeaders([]string{"True-Client-IP"}).IP(r)
	fmt.Fprintf(w, "Your IP address is "+ip+" and dst port "+port)
}

func main() {
	http.HandleFunc("/", root)
	log.Fatal(http.ListenAndServe(":8081", nil))
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].