mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net: byte fixes
This commit is contained in:
@@ -10,13 +10,13 @@ union AddrData {
|
||||
}
|
||||
|
||||
const (
|
||||
addr_ip6_any = [16]byte{init: u8(0)}
|
||||
addr_ip_any = [4]byte{init: u8(0)}
|
||||
addr_ip6_any = [16]u8{init: u8(0)}
|
||||
addr_ip_any = [4]u8{init: u8(0)}
|
||||
)
|
||||
|
||||
fn new_ip6(port u16, addr [16]byte) Addr {
|
||||
fn new_ip6(port u16, addr [16]u8) Addr {
|
||||
a := Addr{
|
||||
f: u16(AddrFamily.ip6)
|
||||
f: u8(AddrFamily.ip6)
|
||||
addr: AddrData{
|
||||
Ip6: Ip6{
|
||||
port: u16(C.htons(port))
|
||||
@@ -29,9 +29,9 @@ fn new_ip6(port u16, addr [16]byte) Addr {
|
||||
return a
|
||||
}
|
||||
|
||||
fn new_ip(port u16, addr [4]byte) Addr {
|
||||
fn new_ip(port u16, addr [4]u8) Addr {
|
||||
a := Addr{
|
||||
f: u16(AddrFamily.ip)
|
||||
f: u8(AddrFamily.ip)
|
||||
addr: AddrData{
|
||||
Ip: Ip{
|
||||
port: u16(C.htons(port))
|
||||
@@ -133,7 +133,7 @@ pub fn resolve_addrs(addr string, family AddrFamily, @type SocketType) ?[]Addr {
|
||||
|
||||
return [
|
||||
Addr{
|
||||
f: u16(AddrFamily.unix)
|
||||
f: u8(AddrFamily.unix)
|
||||
addr: AddrData{
|
||||
Unix: resolved
|
||||
}
|
||||
|
@@ -38,20 +38,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -21,7 +21,7 @@ mut:
|
||||
sin6_family byte // 1
|
||||
sin6_port u16 // 2
|
||||
sin6_flowinfo u32 // 4
|
||||
sin6_addr [16]byte // 16
|
||||
sin6_addr [16]u8 // 16
|
||||
sin6_scope_id u32 // 4
|
||||
}
|
||||
|
||||
@@ -45,20 +45,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -26,7 +26,7 @@ mut:
|
||||
sin6_family byte // 1
|
||||
sin6_port u16 // 2
|
||||
sin6_flowinfo u32 // 4
|
||||
sin6_addr [16]byte // 16
|
||||
sin6_addr [16]u8 // 16
|
||||
sin6_scope_id u32 // 4
|
||||
}
|
||||
|
||||
@@ -50,20 +50,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -24,7 +24,7 @@ mut:
|
||||
sin6_family byte // 1
|
||||
sin6_port u16 // 2
|
||||
sin6_flowinfo u32 // 4
|
||||
sin6_addr [16]byte // 16
|
||||
sin6_addr [16]u8 // 16
|
||||
sin6_scope_id u32 // 4
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -38,20 +38,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -26,7 +26,7 @@ mut:
|
||||
sin6_family byte // 1
|
||||
sin6_port u16 // 2
|
||||
sin6_flowinfo u32 // 4
|
||||
sin6_addr [16]byte // 16
|
||||
sin6_addr [16]u8 // 16
|
||||
sin6_scope_id u32 // 4
|
||||
}
|
||||
|
||||
@@ -50,20 +50,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -24,7 +24,7 @@ mut:
|
||||
sin6_family byte // 1
|
||||
sin6_port u16 // 2
|
||||
sin6_flowinfo u32 // 4
|
||||
sin6_addr [16]byte // 16
|
||||
sin6_addr [16]u8 // 16
|
||||
sin6_scope_id u32 // 4
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
addr [4]u8
|
||||
// Pad to size so that socket functions
|
||||
// dont complain to us (see in.h and bind())
|
||||
// TODO(emily): I would really like to use
|
||||
// some constant calculations here
|
||||
// so that this doesnt have to be hardcoded
|
||||
sin_pad [8]byte
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -38,15 +38,15 @@ mut:
|
||||
struct Ip6 {
|
||||
port u16
|
||||
flow_info u32
|
||||
addr [16]byte
|
||||
addr [16]u8
|
||||
scope_id u32
|
||||
}
|
||||
|
||||
[_pack: '1']
|
||||
struct Ip {
|
||||
port u16
|
||||
addr [4]byte
|
||||
sin_pad [8]byte
|
||||
addr [4]u8
|
||||
sin_pad [8]u8
|
||||
}
|
||||
|
||||
struct Unix {
|
||||
|
@@ -177,7 +177,7 @@ pub fn (c &Cookie) str() string {
|
||||
return b.str()
|
||||
}
|
||||
|
||||
fn sanitize(valid fn (byte) bool, v string) string {
|
||||
fn sanitize(valid fn (u8) bool, v string) string {
|
||||
mut ok := true
|
||||
for i in 0 .. v.len {
|
||||
if valid(v[i]) {
|
||||
@@ -222,11 +222,11 @@ fn sanitize_cookie_path(v string) string {
|
||||
return sanitize(valid_cookie_path_byte, v)
|
||||
}
|
||||
|
||||
fn valid_cookie_value_u8(b byte) bool {
|
||||
fn valid_cookie_value_byte(b u8) bool {
|
||||
return 0x20 <= b && b < 0x7f && b != `"` && b != `;` && b != `\\`
|
||||
}
|
||||
|
||||
fn valid_cookie_path_u8(b byte) bool {
|
||||
fn valid_cookie_path_byte(b u8) bool {
|
||||
return 0x20 <= b && b < 0x7f && b != `!`
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ fn parse_cookie_value(_raw string, allow_double_quote bool) ?string {
|
||||
raw = raw.substr(1, raw.len - 1)
|
||||
}
|
||||
for i in 0 .. raw.len {
|
||||
if !valid_cookie_value_u8(raw[i]) {
|
||||
if !valid_cookie_value_byte(raw[i]) {
|
||||
return error('http.cookie: invalid cookie value')
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ mut:
|
||||
opcode OPCode // interpretation of the payload data
|
||||
has_mask bool // true if the payload data is masked
|
||||
payload_len int // payload length
|
||||
masking_key [4]byte // all frames from client to server is masked with this key
|
||||
masking_key [4]u8 // all frames from client to server is masked with this key
|
||||
}
|
||||
|
||||
const (
|
||||
|
Reference in New Issue
Block a user