Package-Level Type Names (total 13, in which 7 are exported)
/* sort exporteds by: | */
NAT implements facility for Network Address Translation simulation.
Basic example:
[ A ] <-----> [ NAT1 ] <-----> [ NAT2 ] <-----> [ B ]
IPa IPa' IPb' IPb
1) A sends packet P with dst = IPb'
2) NAT1 receives packet P and changes it's src to IPa',
sending it to NAT2 from IPa'.
3) NAT2 receives packet P from IPa' to IPb', does a lookup to
NAT translation table and finds association IPb' <-> IPb.
Then it sends packet P to B.
4) B receives packet P from NAT2, observing that it has src = IPa'.
Now B can repeat steps 1-4 and send packet back.
IPa = 10.5.0.1:30000
IPa' = 83.30.100.1:23100
IPb' = 91.10.100.1:13000
IPb = 10.1.0.1:20000
Net is virtual "net" package, implements mesh of peers.peersmap[string]*PacketConn ListenPacket announces on the local network address. ResolveUDPAddr returns an address of UDP end point.
Time simulates temporal interactions.
All methods are goroutine-safe.momentIDintmomentsmap[int]moment mux guards internal state. Note that all methods without Unlocked
suffix acquire mux.nowtime.Timeobservers[]chan struct{} After returns new channel that will receive time.Time value with current tme after
specified duration. Now returns the current time. Observe return channel that closes on clock calls. The current implementation
also closes the channel on Ticker’s ticks. Set travels to specified time.
Also triggers temporal effects. Sleep blocks until duration is elapsed.(*Time) Ticker(d time.Duration) Ticker(*Time) Timer(d time.Duration) Timer Travel adds duration to current time and returns result.
Also triggers temporal effects. TravelDate applies AddDate to current time and returns result.
Also triggers temporal effects. When returns relative time point.(*Time) observeUnlocked()(*Time) plan(when time.Time, do func(now time.Time)) int(*Time) planUnlocked(when time.Time, do func(now time.Time)) int reset adjusts the moment with the given ID to run after the d duration. It
creates a new moment if the moment does not already exist. If durp pointer
is not nil, it is updated with d value while reset is holding Time’s lock. resetUnlocked is like reset but does not acquire the Time’s lock. setUnlocked sets the current time to the given now time and triggers temporal
effects. stop removes the moment with the given ID from the list of scheduled moments.
It returns true if a moment existed for the given ID, otherwise it is no-op. tickUnlocked applies all scheduled temporal effects.
*Time : github.com/gotd/td/clock.Clock
*Time : github.com/cenkalti/backoff/v4.Clock
func NewTime(now time.Time) *Time
chchan time.Timedurtime.Durationidinttime*Time(*ticker) C() <-chan time.Time(*ticker) Reset(d time.Duration)(*ticker) Stop() do is the ticker’s moment callback. It sends the now time to the underlying
channel and plans a new moment for the next tick. Note that do runs under
Time’s lock.
*ticker : Ticker
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.