Skip to content

Commit

Permalink
Add TinyGo support; Add Cloudflare Workers rendezvous server example
Browse files Browse the repository at this point in the history
Requires the TinyGo fork found at https://github.com/ben-krieger/tinygo/tree/reflect-clear-and-more

Signed-off-by: Ben Krieger <ben.krieger@intel.com>
  • Loading branch information
ben-krieger committed Nov 11, 2024
1 parent 1fef581 commit df07da7
Show file tree
Hide file tree
Showing 27 changed files with 1,190 additions and 389 deletions.
9 changes: 2 additions & 7 deletions cbor/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,15 +1243,10 @@ func (e *Encoder) encodeTextOrBinary(rv reflect.Value) error {

// Unaddressable arrays cannot be made into slices, so we must create a
// slice and copy contents into it
slice := reflect.MakeSlice(
reflect.SliceOf(rv.Type().Elem()),
rv.Len(),
rv.Len(),
)
if n := reflect.Copy(slice, rv); n != rv.Len() {
b = make([]byte, rv.Len())
if n := reflect.Copy(reflect.ValueOf(b), rv); n != rv.Len() {
panic("array contents were not fully copied into a slice for encoding")
}
b = slice.Bytes()
}

info := u64Bytes(uint64(len(b)))
Expand Down
4 changes: 2 additions & 2 deletions di.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func appStart(ctx context.Context, transport Transport, info any) (*VoucherHeade
// Make request
typ, resp, err := transport.Send(ctx, protocol.DIAppStartMsgType, msg, nil)
if err != nil {
return nil, fmt.Errorf("error sending DI.AppStart: %w", err)
return nil, fmt.Errorf("DI.AppStart: %w", err)
}
defer func() { _ = resp.Close() }()

Expand Down Expand Up @@ -296,7 +296,7 @@ func setHmac(ctx context.Context, transport Transport, hmac hash.Hash, ovh *Vouc
// Make request
typ, resp, err := transport.Send(ctx, protocol.DISetHmacMsgType, msg, nil)
if err != nil {
return fmt.Errorf("error sending DI.SetHMAC: %w", err)
return fmt.Errorf("DI.SetHMAC: %w", err)
}
defer func() { _ = resp.Close() }()

Expand Down
Loading

0 comments on commit df07da7

Please sign in to comment.