mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +03:00
Create gh-pages branch via GitHub
This commit is contained in:
parent
595e70c8c5
commit
16570f735b
2 changed files with 12 additions and 2 deletions
12
index.html
12
index.html
|
@ -137,6 +137,16 @@ Protocol: 1
|
|||
</footer>
|
||||
</div>
|
||||
<script src="javascripts/scale.fix.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-39596175-1");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1 +1 @@
|
|||
{"name":"Water","tagline":"A simple TUN/TAP library written in native Go.","body":"# water\r\n`water` is a native Go library for [TUN/TAP](http://en.wikipedia.org/wiki/TUN/TAP) interfaces.\r\n\r\n`water` is designed to be simple and efficient. It\r\n\r\n* wraps almost only syscalls and uses only Go standard types;\r\n* exposes standard interfaces; plays well with standard packages like `io`, `bufio`, etc..\r\n* does not handle memory management (allocating/destructing slice). It's up to user to decide how to deal with buffers; whether to use GC.\r\n\r\n`water/waterutil` has some useful functions to interpret MAC farme headers and IP packet headers. It also contains some constants such as protocol numbers and ethernet frame types.\r\n\r\n## Installation\r\n```\r\ngo get -u github.com/songgao/water\r\ngo get -u github.com/songgao/water/waterutil\r\n```\r\n\r\n## Documentation\r\n[http://godoc.org/github.com/songgao/water](http://godoc.org/github.com/songgao/water)\r\n\r\n[http://godoc.org/github.com/songgao/water/waterutil](http://godoc.org/github.com/songgao/water/waterutil)\r\n\r\n## Example\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"github.com/songgao/water\"\r\n\t\"github.com/songgao/water/waterutil\"\r\n\t\"fmt\"\r\n)\r\n\r\nconst BUFFERSIZE = 1522\r\n\r\nfunc main() {\r\n\tifce, err := water.NewTAP(\"\")\r\n\tfmt.Printf(\"%v, %v\\n\\n\", err, ifce)\r\n\tbuffer := make([]byte, BUFFERSIZE)\r\n\tfor {\r\n\t\t_, err = ifce.Read(buffer)\r\n\t\tif err != nil {\r\n\t\t\tbreak\r\n\t\t}\r\n\t\tethertype := waterutil.MACEthertype(buffer)\r\n\t\tif ethertype == waterutil.IPv4 {\r\n\t\t\tpacket := waterutil.MACPayload(buffer)\r\n\t\t\tif waterutil.IsIPv4(packet) {\r\n\t\t\t\tfmt.Printf(\"Source: %v [%v]\\n\", waterutil.MACSource(buffer), waterutil.IPv4Source(packet))\r\n\t\t\t\tfmt.Printf(\"Destination: %v [%v]\\n\", waterutil.MACDestination(buffer), waterutil.IPv4Destination(packet))\r\n\t\t\t\tfmt.Printf(\"Protocol: %v\\n\\n\", waterutil.IPv4Protocol(packet))\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nThis piece of code creates a `TAP` interface, and prints some header information for every IPv4 packet. After pull up the `main.go`, you'll need to bring up the interface and assign IP address. All of these need root permission.\r\n\r\n```bash\r\nsudo go run main.go\r\n```\r\n\r\n```bash\r\nsudo ip link set dev tap0 up\r\nsudo ip addr add 10.0.0.1/24 dev tap0\r\n```\r\n\r\nNow, try sending some ICMP broadcast message:\r\n```bash\r\nping -b 10.0.0.255\r\n```\r\n\r\nYou'll see the `main.go` print something like:\r\n```\r\n<nil>, &{true 0xf84003f058 tap0}\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n```\r\n\r\n## TODO\r\n* IPv6 Support in `waterutil`\r\n* Darwin(Mac) Support\r\n\r\n## LICENSE\r\nGNU LESSER GENERAL PUBLIC LICENSE Version 3\r\n\r\n## Alternatives\r\n`tuntap`: [https://code.google.com/p/tuntap/](https://code.google.com/p/tuntap/)\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
|
||||
{"name":"Water","tagline":"A simple TUN/TAP library written in native Go.","body":"# water\r\n`water` is a native Go library for [TUN/TAP](http://en.wikipedia.org/wiki/TUN/TAP) interfaces.\r\n\r\n`water` is designed to be simple and efficient. It\r\n\r\n* wraps almost only syscalls and uses only Go standard types;\r\n* exposes standard interfaces; plays well with standard packages like `io`, `bufio`, etc..\r\n* does not handle memory management (allocating/destructing slice). It's up to user to decide how to deal with buffers; whether to use GC.\r\n\r\n`water/waterutil` has some useful functions to interpret MAC farme headers and IP packet headers. It also contains some constants such as protocol numbers and ethernet frame types.\r\n\r\n## Installation\r\n```\r\ngo get -u github.com/songgao/water\r\ngo get -u github.com/songgao/water/waterutil\r\n```\r\n\r\n## Documentation\r\n[http://godoc.org/github.com/songgao/water](http://godoc.org/github.com/songgao/water)\r\n\r\n[http://godoc.org/github.com/songgao/water/waterutil](http://godoc.org/github.com/songgao/water/waterutil)\r\n\r\n## Example\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"github.com/songgao/water\"\r\n\t\"github.com/songgao/water/waterutil\"\r\n\t\"fmt\"\r\n)\r\n\r\nconst BUFFERSIZE = 1522\r\n\r\nfunc main() {\r\n\tifce, err := water.NewTAP(\"\")\r\n\tfmt.Printf(\"%v, %v\\n\\n\", err, ifce)\r\n\tbuffer := make([]byte, BUFFERSIZE)\r\n\tfor {\r\n\t\t_, err = ifce.Read(buffer)\r\n\t\tif err != nil {\r\n\t\t\tbreak\r\n\t\t}\r\n\t\tethertype := waterutil.MACEthertype(buffer)\r\n\t\tif ethertype == waterutil.IPv4 {\r\n\t\t\tpacket := waterutil.MACPayload(buffer)\r\n\t\t\tif waterutil.IsIPv4(packet) {\r\n\t\t\t\tfmt.Printf(\"Source: %v [%v]\\n\", waterutil.MACSource(buffer), waterutil.IPv4Source(packet))\r\n\t\t\t\tfmt.Printf(\"Destination: %v [%v]\\n\", waterutil.MACDestination(buffer), waterutil.IPv4Destination(packet))\r\n\t\t\t\tfmt.Printf(\"Protocol: %v\\n\\n\", waterutil.IPv4Protocol(packet))\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nThis piece of code creates a `TAP` interface, and prints some header information for every IPv4 packet. After pull up the `main.go`, you'll need to bring up the interface and assign IP address. All of these need root permission.\r\n\r\n```bash\r\nsudo go run main.go\r\n```\r\n\r\n```bash\r\nsudo ip link set dev tap0 up\r\nsudo ip addr add 10.0.0.1/24 dev tap0\r\n```\r\n\r\nNow, try sending some ICMP broadcast message:\r\n```bash\r\nping -b 10.0.0.255\r\n```\r\n\r\nYou'll see the `main.go` print something like:\r\n```\r\n<nil>, &{true 0xf84003f058 tap0}\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n\r\nSource: 42:35:da:af:2b:00 [10.0.0.1]\r\nDestination: ff:ff:ff:ff:ff:ff [10.0.0.255]\r\nProtocol: 1\r\n```\r\n\r\n## TODO\r\n* IPv6 Support in `waterutil`\r\n* Darwin(Mac) Support\r\n\r\n## LICENSE\r\nGNU LESSER GENERAL PUBLIC LICENSE Version 3\r\n\r\n## Alternatives\r\n`tuntap`: [https://code.google.com/p/tuntap/](https://code.google.com/p/tuntap/)\r\n","google":"UA-39596175-1","note":"Don't delete this file! It's used internally to help with page regeneration."}
|
Loading…
Add table
Add a link
Reference in a new issue