GithubHelp home page GithubHelp logo

stun-test's Introduction

Stun 测试

1、Stun Server

jselbie/stunserver

# 启动 server 服务。默认tcp/udp 端口均为3478
stunserver.exe

2、Stun Client

nodertc/stun

# 安装 stun 类库
npm i stun
// 引入 stun
const stun = require('stun');

// 测试连接到 stun 服务器
stun.request('localhost:3478').then(res=>{
    console.log(res);
    console.log('your ip', res.getXorAddress().address);
});
# 返回结果
<ref *1> StunResponse {
  [Symbol(kMessageType)]: 257,
  [Symbol(kTransctionId)]: <Buffer d0 ae 6a fa 60 f2 86 69 95 e6 cd 32>,
  [Symbol(kCookie)]: 554869826,
  [Symbol(kAttributes)]: [
    StunAddressAttribute {
      [Symbol(kAttributeType)]: 1,
      [Symbol(kPort)]: 54765,
      [Symbol(kAddress)]: '127.0.0.1',
    },
    StunAddressAttribute {
      [Symbol(kPort)]: 3478,
      [Symbol(kAddress)]: '127.0.0.1',
      [Symbol(kFamily)]: 'IPv4'
    },
    StunXorAddressAttribute {
      [Symbol(kAttributeType)]: 32,
      [Symbol(kPort)]: 54765,
      [Symbol(kAddress)]: '127.0.0.1',
      [Symbol(kFamily)]: 'IPv4',
      [Symbol(kOwner)]: [Circular *1]
    }
  ]
}
your ip 127.0.0.1

详细使用查看官方文档

stun-test's People

Contributors

gearinger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.