How to get the default gateway?

xuanbao · · 1931 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Is there any cross platform solution (native lib) to get the default gateway? golang.org/x/net/route is <a href="https://gist.github.com/abimaelmartell/dcbbff464dc0778165b2dcc5092f90e6">BSD only</a>, so not even Linux and not to mention Windows.</p> <hr/>**评论:**<br/><br/>jammerlt: <pre><p><a href="https://github.com/jackpal/gateway">https://github.com/jackpal/gateway</a></p></pre>Chohmoh: <pre><p>Thx, didn&#39;t found it. I usually prefer not to rely on an exec of a binary which might not even be found and than parse it&#39;s ASCII output, but for my use case it&#39;s sufficient. Case solved. :)</p></pre>Chuiken: <pre><p><a href="https://github.com/vishvananda/netlink/blob/master/route.go#L35" rel="nofollow">https://github.com/vishvananda/netlink/blob/master/route.go#L35</a></p></pre>Chohmoh: <pre><blockquote> <p>Netlink is the interface a user-space program in linux uses to communicate with the kernel.</p> </blockquote> <p>That&#39;s Linux only.</p></pre>hell_0n_wheel: <pre><p>Why do you need to grab the gateway? The network stack abstracts that need away from you...</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1931 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传