# README
Mule
Mule is a Go library that provides a convenient way to send UDP packets to multiple remote servers with unreachable ports and receive ICMP Destination/Port Unreachable packets from those servers. This can be useful for network diagnostics, port scanning, or other network-related tasks.
Features
- Send UDP packets to specified IP addresses and ports
- Receive and parse ICMP Destination Unreachable messages
- Configurable connection options (local IP, timeout, TOS, TTL, IPv4 flags)
- Easy-to-use API compatible with
net.Conn
interface
Installation
To install Mule, use go get
:
go get github.com/smallnest/mule
Usage
Here's a basic example of how to use Mule:
package main
import (
"context"
"fmt"
"net"
"time"
)
func main() {
muleConn, err := mule.New(
mule.WithLocalIP("192.168.1.1"),
mule.WithTimeout(5*time.Second),
mule.WithTTL(64),
mule.WithTOS(0),
mule.WithIPv4Flag(0),
)
if err != nil {
log.Fatalf("failed to create mule connection: %v", err)
}
defer muleConn.Close()
// send a UDP packet
_, err = muleConn.WriteToIP([]byte("Hello, Mule!"), "192.168.1.2", 1234, 80)
if err != nil {
log.Fatalf("failed to send UDP packet: %v", err)
}
// read the ICMP response
dstIP, srcPort, dstPort, err := muleConn.ReadFrom()
if err != nil {
log.Fatalf("failed to read ICMP response: %v", err)
}
fmt.Printf("received ICMP response: dstIP=%s, srcPort=%d, dstPort=%d\n", dstIP, srcPort, dstPort)
}
# Packages
No description provided by the author
# Functions
New creates a new Mule connection with the given options.
WithIPv4Flag sets the IPv4 flag for the connection.
WithLocalIP sets the local IP address for the connection.
WithTimeout sets the timeout duration for the connection.
WithTOS sets the Type of Service (TOS) for the connection.
WithTTL sets the Time To Live (TTL) for the connection.