87 Commits
Author SHA1 Message Date
xtaci 8fd6d90d50 perf(test): reduce 1GB echo allocations and random overhead
- Reuse buffers and use rng.Read to cut per-iteration allocations in random echo test
- Separate RNG for payload length to keep data stream deterministic
- Optimize UDP source validation by comparing UDPAddr directly to avoid per-packet String allocation
2026-01-26 11:23:51 +08:00
xtaci b893d5527e fix tests 2025-12-28 21:17:15 +08:00
xtaci 53c14d4570 refactor: unify and simplify OOB handler interface for UDPSession
- Replace atomic.Pointer[func([]byte)] with atomic.Value for OOB callback storage to improve compatibility.
- Rename SetCallbackForOOB to SetOOBHandler and GetMaxSizeForOOB to GetOOBMaxSize for clearer, consistent API naming.
- Add locking in SendOOB to ensure thread safety during OOB packet construction.
- Update related test cases in sess_test.go to use the new interface names.
- Revise comments and documentation for better clarity and maintainability.

user takes care of the nil handler

use 0xffffffff as the seqid of OOB

return error on nil handler

fix race in test

shorten test data size

add more test on OOB

enhance Error test

allow nil from sender side

add OOBPackets in snmp

use dummy handler instead of resetting the atomic.Value

add test for dummy handler

remove a comment

formalize callback function prototype

use const

rename to expose

Add comments to clarify KCP input and FEC decoding order for FEC packets.

fix test

comments

add TestOOB_OneSideHandler
2025-12-27 23:25:03 +08:00
Lonny Wong eb7d8ee32f Add out-of-band (OOB) data support 2025-12-27 10:12:56 +08:00
xtaci f53a3373f8 optimize: modernize -fix -test . 2025-12-22 13:10:47 +08:00
xtaci 052b09682f refine tests for better coverage
mv entropy related test to entropy_test.go
2025-12-19 21:59:05 +08:00
xtaci 97eca2ce79 remove return after panic 2025-12-14 18:10:27 +08:00
xtaci 364d628d03 add 6GB echo to test wrap around 4GB boundary 2025-12-11 21:29:05 +08:00
xtaci 41b9affb8a added 1GB echo test 2025-12-11 20:47:08 +08:00
Coia Prant 7ea501b3ba chores: check aead allocate in tests 2025-12-11 20:07:23 +08:00
Coia Prant be05230334 chores: add overhead panic tests 2025-12-11 19:35:45 +08:00
xtaci dd720305cb reinforce sendvector test 2025-12-11 16:07:10 +08:00
xtaci 834190bb8f use hi port in test 2025-12-11 16:01:53 +08:00
xtaci d27b435754 seperate salsa20 test 2025-12-11 13:11:07 +08:00
xtaci 75a223bd68 add an explicit setting headerSize to 0 2025-12-11 13:03:40 +08:00
xtaci f3867e64e2 complete tests of 3 types of transport: CFB, AEAD, and plaintext 2025-12-11 12:48:34 +08:00
xtaci d255fb80d8 update NewAEADCrypt 2025-12-10 22:01:46 +08:00
xtaci 2e3730ea5b update test to use random echo test 2025-12-10 21:54:37 +08:00
xtaci 6dbb27cf2c enhance test structure 2025-12-10 20:56:58 +08:00
xtaci c73962fe8f adjust AEAD function initialization 2025-12-10 20:41:36 +08:00
Coia Prant 6fa78d3144 refactor: use modern syntax for test & example (#317) 2025-12-09 17:19:25 +08:00
xtaci d8b28827ef fix mtu calc 2025-12-09 11:13:05 +08:00
xtaci 7fa14a0cee Squashed commit of the following:
commit 6568f08d6c
Author: binhu <jinnblue@126.com>
Date:   Mon Dec 8 22:32:29 2025 +0800

    fix(sess): revert WriteBuffers Send use kcp fragment; make TestSetMTU correct.

commit 7822300957
Author: jinnblue <jinnblue@126.com>
Date:   Mon Dec 8 00:48:01 2025 +0800

    fix(sess): panic caused by mtu, when fec/crypt opened and mss < mtu <= mtulimit

commit b651b55aec
Author: jinnblue <jinnblue@126.com>
Date:   Sun Dec 7 21:58:54 2025 +0800

    fix(sess): use correct field(wd) for write deadlines; kcp output non-blocking chPostProcessing avoid deadlocks(mu)
2025-12-08 22:45:00 +08:00
JinnBlue b6e37c405b fix(trace): fix incorrectly trace log (#309) 2025-11-26 11:07:08 +08:00
JinnBlue a32123b5dc feat(trace): add trace log to enhance KCP debug (#308)
* feat(trace): add trace log to enhance KCP debug

* feat(trace): update comments
2025-11-22 12:00:20 +08:00
xtaci fe591de1d9 implement a userspace pacing 2025-11-15 21:11:44 +08:00
xtaci 5699c14164 optimize echo test 2025-11-13 20:42:17 +08:00
xtaci 56de076e83 Squashed commit of the following:
commit 745517fcc4
Author: xtaci <imap@live.com>
Date:   Fri Jun 6 11:13:27 2025 +0800

    fix grow

commit 1b6d34570a
Author: xtaci <imap@live.com>
Date:   Fri Jun 6 10:48:07 2025 +0800

    Squashed commit of the following:

    commit 8f90af5057
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:46:52 2025 +0800

        add ForEach in ringbuffer

    commit 82250c1f06
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:29:23 2025 +0800

        add test for grow()

    commit 174824b596
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:08:05 2025 +0800

        remove fmt.Print

    commit 6534dfe542
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:06:18 2025 +0800

        rename to ringbuffer

    commit 2f44ba9a82
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:03:14 2025 +0800

        add comments

    commit 3f49975468
    Author: xtaci <imap@live.com>
    Date:   Fri Jun 6 10:02:14 2025 +0800

        save

    commit c505f434cc
    Author: xtaci <daniel820313@gmail.com>
    Date:   Thu Jun 5 17:47:17 2025 +0800

        add ring

commit 3b4daea2cd
Author: FULI <daniel820313@gmail.com>
Date:   Fri Jun 6 10:30:51 2025 +0800

    RingBuffer (#290)

    * add ring

    * save

    * add comments

    * rename to ringbuffer

    * remove fmt.Print

    * add test for grow()

commit e0169fb60e
Author: xtaci <imap@live.com>
Date:   Sun May 25 00:09:13 2025 +0800

    make fec.go more clear

commit 97d2673e8a
Author: xtaci <imap@live.com>
Date:   Wed May 21 13:55:08 2025 +0800

    add comments to fec.go

commit 5ef7e8042f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue May 20 10:38:46 2025 +0800

    Bump golang.org/x/net from 0.36.0 to 0.38.0 (#287)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.36.0 to 0.38.0.
    - [Commits](https://github.com/golang/net/compare/v0.36.0...v0.38.0)

    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-version: 0.38.0
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 11ae2d1c3e
Author: xtaci <imap@live.com>
Date:   Tue Apr 15 10:40:08 2025 +0800

    update go.mod

commit 53b48e42c2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Apr 15 10:38:02 2025 +0800

    Bump golang.org/x/net from 0.23.0 to 0.36.0 (#286)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.36.0.
    - [Commits](https://github.com/golang/net/compare/v0.23.0...v0.36.0)

    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-version: 0.36.0
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit f327c26f53
Author: Roman Gurov <44749519+rgurov@users.noreply.github.com>
Date:   Fri Apr 11 05:11:14 2025 +0300

    fix: typo in README.md (#284)

commit c5078bd33b
Author: Roman Gurov <44749519+rgurov@users.noreply.github.com>
Date:   Wed Apr 9 10:44:14 2025 +0300

    fix: make timeout error implement net.Error (#283)

commit 3c579515d6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Feb 18 14:33:01 2025 +0800

    Bump golang.org/x/crypto from 0.21.0 to 0.31.0 (#281)

    Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.31.0.
    - [Commits](https://github.com/golang/crypto/compare/v0.21.0...v0.31.0)

    ---
    updated-dependencies:
    - dependency-name: golang.org/x/crypto
      dependency-type: direct:production
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 5c80bedd4b
Author: xiabin <snyh@snyh.org>
Date:   Fri Dec 27 13:08:22 2024 +0800

    fix: reading low-level net.PacketConn when UDPSession is closed (#280)
2025-06-06 11:18:40 +08:00
xtaci 0b3010f130 add control func test 2024-08-23 22:42:16 +08:00
xtaci bf6f88f918 do not reserve in kcp core, reserve bytes in callback func 2024-07-31 14:57:52 +08:00
xtaci 3653cc9fea add license to source codes 2024-07-25 21:35:37 +08:00
xtaci cd06d59cba Squashed commit of the following:
commit 0e5741b954
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 16:21:42 2024 +0800

    use latest packet compare

commit 97999b9dc2
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 16:07:08 2024 +0800

    face race in test

commit 446bead851
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 16:04:42 2024 +0800

    upd

commit 570e9b006e
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 16:03:17 2024 +0800

    revert some file

commit c665db20a5
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 15:59:16 2024 +0800

    Revert "Revert "1. simplify readloop_xxx files & tx_xxx files by merging""

    This reverts commit 717b79a156.

commit 717b79a156
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 15:58:30 2024 +0800

    Revert "1. simplify readloop_xxx files & tx_xxx files by merging"

    This reverts commit 681bda64d1.

commit 681bda64d1
Author: fuli <fuli@rockx.com>
Date:   Thu Jan 4 15:54:29 2024 +0800

    1. simplify readloop_xxx files & tx_xxx files by merging
    2. fix the race in owned packet test

commit 7974357dd0
Author: xtaci <daniel820313@gmail.com>
Date:   Thu Jan 4 00:04:06 2024 +0800

    use unix.Milli

commit 375407b80c
Author: xtaci <daniel820313@gmail.com>
Date:   Wed Jan 3 23:40:01 2024 +0800

    add passive fec
2024-01-04 22:43:12 +08:00
xtaci 582575ef06 Squashed commit of the following:
commit a8ae293a9ddee042c35e2501f93fa5dfa2425302
Merge: bdaf81e 1a84985
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 22:48:13 2020 +0800

    Merge branch 'master' into autotune

commit bdaf81e88e
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 22:38:31 2020 +0800

    add loc

commit ce66a98f95
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 19:53:42 2020 +0800

    lint

commit ad7383d8a3
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 19:05:35 2020 +0800

    fix typo

commit dc0fc2364c
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:47:14 2020 +0800

    adjust tests

commit ec45b72c39
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:45:17 2020 +0800

    remove obsolete decoder in listener

commit 827aa70e29
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:42:42 2020 +0800

    use hierarchical defensive receiving strategy

commit f5ca6b0e3a
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:34:30 2020 +0800

    optimize condition

commit ff34f7683f
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:18:00 2020 +0800

    fix test

commit a08b274651
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:13:20 2020 +0800

    solve compability issue with non FEC sender

commit ab7596783b
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:02:34 2020 +0800

    implements autotune in fec decoder

commit 260f61b3eb
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 14:34:48 2020 +0800

    hack 16-bit to identify FEC from packet

commit 105bfec567
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 2 21:38:47 2020 +0800

    add autotune
2020-10-09 22:52:11 +08:00
Eudi4HandDavid Fifield bb1f2af922 Make UDPSession and Listener only close PacketConns they created (#167)
* Tests for closing owned/non-owned PacketConns (#165)

* Don't close non-owned conns in UDPSession and Listener (#165)

Co-authored-by: David Fifield <david@bamsoftware.com>
2020-03-18 11:23:06 +08:00
xtaci af0ce8f01d proper error handling 2019-05-13 16:31:28 +08:00
xtaci e3e2ef6795 upd test 2019-05-09 18:33:39 +08:00
xtaci cfc0c8e463 error handling 2019-05-09 16:31:52 +08:00
xtaci f0e07abcce close opened conns in tests 2019-05-08 21:53:41 +08:00
xtaci 8078536338 upd tests 2019-05-08 21:39:09 +08:00
xtaci c340cca9d7 fix 2019-05-08 21:09:47 +08:00
xtaci 7c104a5443 add WriteBuffers function to send a vector of slice in batch 2019-04-07 21:56:50 +08:00
xtaci 2e7567b77e adjust tests,avoid overflow of netdev 2019-01-09 23:17:17 +08:00
xtaci 2500c38813 lint 2018-12-27 15:05:38 +08:00
xtaci 62a110c3c5 if wnd too large while buf small, sometimes krnl w drop pkts, adjust tests 2018-12-25 15:38:26 +08:00
xtaci ec600818e1 Fix a servere bug introduce in blacklist, server will never proceed with FEC packet
Revert "Key connections by addr+convId, reset cache key on disconnect"

This reverts commit 686d6e0080.
2018-08-10 21:54:59 +08:00
Audrius Butkevicius 81872260d8 Use struct for key, fix bug where lastKey was set to addr only 2017-10-14 17:19:50 +01:00
Audrius Butkevicius 02298ef4d9 Fix tests 2017-10-07 18:39:09 +01:00
xtaci 27888da3bd add testing fuction setdup 2017-04-06 20:55:39 +08:00
xtaci eb6251c51b add extra tests for listener 2017-03-30 12:47:22 +08:00
xtaci c4aa1e2a37 update test 2017-03-28 18:21:06 +08:00