forked from tinygo-org/net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stub out more types/funcs to compile against golang.org/x/net/interna…
…l/socket These are changes need to compile github.com/domainr/dnsr/ with TinyGo. See issue tinygo-org#14. These change are mostly to fix missing symbols in src/net. Missing types and functions are cut-and-pasted from go1.21.4. Functions are stubbed out returning errors.New("not implemented"). DNRS is compiled by running tinygo test: sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi With this patch, and a corresponding patch for tinygo/ to fixup crypto/tls, you should get a clean compile.
- Loading branch information
1 parent
4f0d965
commit 4cc45db
Showing
10 changed files
with
413 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// TINYGO: The following is copied and modified from Go 1.21.4 official implementation. | ||
|
||
// Copyright 2011 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package net | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
// BUG(mikio): On JS, methods and functions related to | ||
// Interface are not implemented. | ||
|
||
// BUG(mikio): On AIX, DragonFly BSD, NetBSD, OpenBSD, Plan 9 and | ||
// Solaris, the MulticastAddrs method of Interface is not implemented. | ||
|
||
var ( | ||
errInvalidInterface = errors.New("invalid network interface") | ||
errInvalidInterfaceIndex = errors.New("invalid network interface index") | ||
errInvalidInterfaceName = errors.New("invalid network interface name") | ||
errNoSuchInterface = errors.New("no such network interface") | ||
errNoSuchMulticastInterface = errors.New("no such multicast network interface") | ||
) | ||
|
||
// Interface represents a mapping between network interface name | ||
// and index. It also represents network interface facility | ||
// information. | ||
type Interface struct { | ||
Index int // positive integer that starts at one, zero is never used | ||
MTU int // maximum transmission unit | ||
Name string // e.g., "en0", "lo0", "eth0.100" | ||
HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form | ||
Flags Flags // e.g., FlagUp, FlagLoopback, FlagMulticast | ||
} | ||
|
||
type Flags uint | ||
|
||
const ( | ||
FlagUp Flags = 1 << iota // interface is administratively up | ||
FlagBroadcast // interface supports broadcast access capability | ||
FlagLoopback // interface is a loopback interface | ||
FlagPointToPoint // interface belongs to a point-to-point link | ||
FlagMulticast // interface supports multicast access capability | ||
FlagRunning // interface is in running state | ||
) | ||
|
||
var flagNames = []string{ | ||
"up", | ||
"broadcast", | ||
"loopback", | ||
"pointtopoint", | ||
"multicast", | ||
"running", | ||
} | ||
|
||
func (f Flags) String() string { | ||
s := "" | ||
for i, name := range flagNames { | ||
if f&(1<<uint(i)) != 0 { | ||
if s != "" { | ||
s += "|" | ||
} | ||
s += name | ||
} | ||
} | ||
if s == "" { | ||
s = "0" | ||
} | ||
return s | ||
} | ||
|
||
// Interfaces returns a list of the system's network interfaces. | ||
func Interfaces() ([]Interface, error) { | ||
return nil, errors.New("Interfaces not implemented") | ||
} | ||
|
||
// InterfaceByIndex returns the interface specified by index. | ||
// | ||
// On Solaris, it returns one of the logical network interfaces | ||
// sharing the logical data link; for more precision use | ||
// InterfaceByName. | ||
func InterfaceByIndex(index int) (*Interface, error) { | ||
return nil, errors.New("InterfaceByIndex not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// TINYGO: The following is copied and modified from Go 1.21.4 official implementation. | ||
|
||
// Copyright 2012 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package net | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
// LookupPort looks up the port for the given network and service. | ||
// | ||
// LookupPort uses context.Background internally; to specify the context, use | ||
// Resolver.LookupPort. | ||
func LookupPort(network, service string) (port int, err error) { | ||
return 0, errors.New("net:LookupPort not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.