Comments (6)
What does the ipv6 address data look like as an array of bytes in the connect token that you generate?
from netcode.
I would expect the array of bytes should look like:
0x00000000000000000000000000000100
Which when read into a uint16_t should look like:
0x0001 in the uint16 value?
from netcode.
(because little endian switches byte order from a uint16 when its read in from memory, while big endian does not... but for both little endian and big endian, the format of a uint16_t in register is the same).
from netcode.
So net.IP (which stores the ip address as a series of bytes) shows:
net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}
the code i use to write/serialize it to the connect token buffer:
for i := 0; i < len(parsed); i += 2 {
var n uint16
n = binary.BigEndian.Uint16([]byte(parsed[i : i+2]))
buffer.WriteUint16(n)
}
shows: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0}
if i change the binary.BigEndian.Uint16 to binary.LittleEndian.Uint16(...) i get:
[]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}
(Note that buffer.WriteUint16(n) does the following):
b.Buf[b.Pos] = byte(n)
b.Pos++
b.Buf[b.Pos] = byte(n >> 8)
b.Pos++
from netcode.
So giving this some more thought, I think the reason is completely on my side, since net.IP already stores it in big endian, converting those bytes again to big endian again actually flips it back to being little endian. We can probably close this.
from netcode.
Makes sense. There are similar endian issues in the C API for parsing IP addresses too, it's tricky.
from netcode.
Related Issues (20)
- Why is the browser plugin archived? HOT 2
- [Question] Connect Token private part HOT 1
- [Question] Is it possible to handle direct IP connections without a matchmaker service? HOT 1
- Assert on NULL user_data in netcode_generate_connect_token() HOT 1
- Up-to-date rust implementation of netcode HOT 1
- Windows: Connecting to server is delayed if some previous clients do not shutdown by the right way HOT 25
- Wait upon certain time for incoming packets HOT 1
- Embed the `client index` to `connection payload packet` and `connection disconnect packet` HOT 5
- libsodium is /MT HOT 1
- Question: Connect Token Design HOT 5
- Connect Token Sniffing HOT 11
- DoS by Abusing Replay Protection HOT 5
- netcode.io support x32? HOT 1
- Settings #define's HOT 14
- MinGW linker error introduced in #66 HOT 1
- Fiy, found Socketify https://socketify.net/
- Switching between carrier and wifi when a connection has been established HOT 2
- netcode.io connect tokens fail when letting the system assign a server port. HOT 2
- Reporting security vulnerabilities HOT 1
- Single project c file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netcode.