Commit Graph

54 Commits

Author SHA1 Message Date
deadprogram a3417d034f Add upgrade automation script and tooling
- upgrade.sh: automates backporting upstream Go net package changes
  - Downloads Go source tarballs for CUR and UPSTREAM versions
  - Copies unmodified files directly from upstream
  - Performs 3-way merge (diff3) for TinyGo-modified files
  - Detects per-file CUR version from TINYGO headers
  - Generates detailed diff reports in .upgrade-report/
  - Supports --dry-run mode for previewing changes
- .gitignore: add .upgrade-work/ and .upgrade-report/ directories
2026-04-13 22:52:34 +01:00
Itxaka fbef30f4ed feat: add pprof package (#44)
Signed-off-by: Itxaka <itxaka@kairos.io>
2026-04-01 16:49:26 +02:00
Itxaka 3f2503bfe4 Add httputil package
Signed-off-by: Itxaka <itxaka@kairos.io>
2026-04-01 16:40:18 +02:00
Char bb43b40f19 http: add CheckRedirect field to Client for compatibility with oauth2
This change introduces a CheckRedirect field to the http.Client struct in TinyGo, 
mirroring the behavior of Go's standard library http.Client.

The purpose of this addition is to resolve build errors in projects that rely 
on packages (such as golang.org/x/oauth2) expecting the Client to have a 
CheckRedirect field. The field provides no functional change within TinyGo’s 
HTTP client at this time — it is only included for API compatibility and 
compilation success. There is no effect on runtime behavior unless explicitly 
used by downstream code.
2025-09-18 01:04:30 -04:00
v1rtl 983d88dd7a add stub httptrace methods and interfaces 2025-08-10 12:22:57 +02:00
Dmytro 77be3968d1 add support for PathValue and SetPathValue from go v1.23.7 (#38)
* add support for PathValue and SetPathValue from go v1.23.7
* add TINYGO notice to pattern.go, proper copy paste of PathValue func
2025-06-11 14:26:56 +02:00
Scott Feldman ca7cd08f85 add lookupProtocol for windows
This fixes a problem with https://github.com/tinygo-org/net/pull/36
which causes the Windows TinyGO build to fail.  The problem is the
function lookupProtocol was missing for Windows build.  This PR adds the
function for Windows.

I can't really test this because I don't have a Windows system, but by
inspection is seems like it's correct.
2025-02-17 12:31:16 +01:00
Scott Feldman 4927c84aa4 net: implement ResolveIPAddr with stub for lookupProtocol, take #2
This is a rework of PR#24 based on review comments.  The rework mostly
involved moving changes to the proper files, aligning with upstream Go
src/net file layout.
2025-01-07 13:35:09 +01:00
Dmitry Shemin e4c3cdf599 Add httptest package 2025-01-04 23:37:56 +01:00
Scott Feldman a237059610 add NOP netdev as default
Initialize netdev to dummy NOP netdev that gracefully errors out all netdev
interface calls.  This is to catch cases where useNetdev() was not
called by the app to set netdev.
2024-07-20 15:46:21 +02:00
Ethan Lewis 7f3a3c9177 fix: add missing UnknownNetworkError 2024-07-16 07:57:37 +02:00
Rajat Jindal 001ceab784 add bare minimum DefaultTransport (#32)
* add bare minimum DefaultTransport

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>

* use transport if explicitly configured by client

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>

---------

Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
2024-07-09 13:26:29 -07:00
Christian Stewart d9132d2a52 net: add ResolveUnixAddr
Signed-off-by: Christian Stewart <christian@aperture.us>
2024-04-13 12:33:35 +02:00
deadprogram a79417481d net: add back Buffers implementation which got lost along the way to the switchover to this package
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-03-09 10:19:45 -05:00
Elias Naur fcee4f5c46 add InterfaceAddrs stub
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2023-12-31 10:46:32 +01:00
Scott Feldman c134160ae4 correct netdever Accept() prototype
According to man page accept(2), accept returns new client sockfd and
remote peer ip:port.  This patch corrects the Accept() prototype in the
netdever interface to not take in an ip:port arg, but rather return an
ip:port for remote peer.
2023-12-18 10:15:35 +01:00
Scott Feldman 4bc93e2fd8 stub out more types/funcs to compile against golang.org/x/net/internal/socket (#17)
* stub out more types/funcs to compile against golang.org/x/net/internal/socket

These are changes need to compile github.com/domainr/dnsr/ with TinyGo. See issue tinygo-org/net#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.
2023-12-17 15:29:45 +01:00
deadprogram 4f0d9658ab tcpsock: define TCPListener as listener
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-12-09 10:34:42 +01:00
soypat 1c4a014aa7 add some docs to netdev interface 2023-12-08 14:21:22 +01:00
deadprogram 5fb7acc7b0 http: add Client RoundTripper/Transport
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-12-08 00:26:31 +01:00
Scott Feldman d6e5efd40a fix 'panic: runtime error: slice smaller than array' bug 2023-12-06 07:46:58 +01:00
soypat 1c04b2c40d fix netdev.Addr docstring 2023-12-04 11:38:39 +01:00
soypat f3548296e1 refurbish internal netdever interface to use netip types instead of net.IP 2023-12-04 11:38:39 +01:00
Scott Feldman 7c11b88ce6 update with changes from go1.20.5 to go1.21.4 2023-11-24 18:26:04 +01:00
Scott Feldman be25e1a28e revert some changes going from 1.19.3 to 1.20.5
There are some new features added in Go 1.20 like string.CutPrefix.
Those will have to wait to be ported until TinyGo MIN is >= 1.20.
2023-07-07 20:00:29 +02:00
Scott Feldman c3616d9365 update 'net' package from 1.19.3 to 1.20.5 2023-07-07 20:00:29 +02:00
Scott Feldman d0c97a5292 README: add documentation on maintaining 'net' package 2023-07-07 20:00:29 +02:00
Scott Feldman 8612dcd77b netdev: improve documentation
Call out netdev as L3/L4 interface for TinyGo, to differentiate between
netlink which is stricly L2.
2023-07-07 20:00:29 +02:00
Scott Feldman 044dc8d374 netdev: move GetIPAddr() from netlink to netdev
Netlink is for L2; netdev is for L3/L4
2023-07-07 20:00:29 +02:00
Scott Feldman 1b87eff727 add ErrClosed error type for natiu-mqtt 2023-07-07 20:00:29 +02:00
Scott Feldman 6bb697535a Unexport net constants copied over from syscall 2023-07-07 20:00:29 +02:00
Scott Feldman 2d46776c18 move syscall constants for networking into net space to avoid windows build issue 2023-07-07 20:00:29 +02:00
Scott Feldman d939a800a7 BUG Fix: use port :80 if server.Addr is empty 2023-07-07 20:00:29 +02:00
Scott Feldman 7898c5e946 BUG Fix: return proper net.OpError's for Read/Write operations
Need to return the same error structure/content as regular Go for
net.Conn Read/Write operations.  Found/fixed when testing deadlines
on Read/Write operations.
2023-07-07 20:00:29 +02:00
Scott Feldman ad745d61ae udpsock: remove TODO comment on ephemeral ports being racy 2023-07-07 20:00:29 +02:00
Scott Feldman 331151cafe move IPPROTO_TLS to netdev to avoid src/syscall dependency 2023-07-07 20:00:29 +02:00
Scott Feldman 693edae782 Add network device driver model, netdev
This PR adds a network device driver model called netdev. There will be a companion PR for TinyGo drivers to update the netdev drivers and network examples. This PR covers the core "net" package.

An RFC for the work is here: #tinygo-org/drivers#487. Some things have changed from the RFC, but nothing major.

The "net" package is a partial port of Go's "net" package, version 1.19.3. The src/net/README file has details on what is modified from Go's "net" package.

Most "net" features are working as they would in normal Go. TCP/UDP/TLS protocol support is there. As well as HTTP client and server support. Standard Go network packages such as golang.org/x/net/websockets and Paho MQTT client work as-is. Other packages are likely to work as-is.

Testing results are here (https://docs.google.com/spreadsheets/d/e/2PACX-1vT0cCjBvwXf9HJf6aJV2Sw198F2ief02gmbMV0sQocKT4y4RpfKv3dh6Jyew8lQW64FouZ8GwA2yjxI/pubhtml?gid=1013173032&single=true).
2023-07-07 20:00:29 +02:00
Justin A. Wilson b46e2ec2ac Added missing TCPAddr and UDPAddr implementations to the net package 2023-05-04 13:35:26 +02:00
Yurii Soldak d6afd8a0f4 build: drop deprecated build tags 2023-05-04 13:35:26 +02:00
Hrishi Hiraskar f8c068c541 net: implement Pipe 2023-05-04 13:35:26 +02:00
Roman Volosatovs ca9cd0d2e5 net: sync net.go with Go 1.18 stdlib
Signed-off-by: Roman Volosatovs <roman@profian.com>
2023-05-04 13:35:26 +02:00
Ayke van Laethem 6787459018 all: format code according to Go 1.19 rules
Go 1.19 started reformatting code in a way that makes it more obvious
how it will be rendered on pkg.go.dev. It gets it almost right, but not
entirely. Therefore, I had to modify some of the comments so that they
are formatted correctly.
2023-05-04 13:35:26 +02:00
Ayke van Laethem 00d8c4d7df all: run gofmt on all source code
Some source code wasn't part of `FMT_PATHS` so wasn't checked for
correct formatting. This change includes all this source code and
excludes cgo/testdata because it contains files that can't be parsed.
2023-05-04 13:35:26 +02:00
Federico G. Schwindt 2953128831 Test net.Buffers{} 2023-05-04 13:35:26 +02:00
Federico G. Schwindt c954718d79 Add net.Buffers
Should fix https://github.com/mailru/easyjson/issues/335, for the
most part.
2023-05-04 13:35:26 +02:00
deadprogram c454821d41 net/interface: use internal implementation for itoa.Uitoa
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-05-04 13:35:26 +02:00
soypat 1714e7c7ab net: add bare Interface implementation 2023-05-04 13:35:26 +02:00
Dan Kegel 2ec51fb1f1 net/ip, syscall/errno: Reduce code duplication by switching to internal/itoa.
internal/itoa wasn't around back in go 1.12 days when tinygo's syscall/errno.go was written.
It was only added as of go 1.17 ( https://github.com/golang/go/commit/061a6903a232cb868780b )
so we have to have an internal copy for now.
The internal copy should be deleted when tinygo drops support for go 1.16.

FWIW, the new version seems nicer.
It uses no allocations when converting 0,
and although the optimizer might make this moot, uses
a multiplication x 10 instead of a mod operation.
2023-05-04 13:35:26 +02:00
soypat 641c70fa39 move xtoi2 to parse.go 2023-05-04 13:35:26 +02:00
Patricio Whittingslow 46ead638e7 add MAC address implementation to net 2023-05-04 13:35:26 +02:00