| Age | Commit message (Collapse) | Author |
|
Since Go 1.20, the standard bytes package have the Copy function.
Since Go 1.22, the standard slices package have the Concat function.
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
This fix some linter warnings on dummy methods and handlers.
|
|
When the goroutine for upgrade, reader, or pinger does not receive
any input from its queue after N duration, stop it.
Currently, N equal to ServerOptions ReadWriteTimeout.
This allow unused goroutines released back to system, minimizing
resources usage.
|
|
|
|
The maximum goroutines is quarter of max queue.
The new goroutine for pinger will be dispatched when no goroutine can
consume the current processed connection.
|
|
Adding prefix provide better way to locate and debug the error in the
future.
|
|
The Server now dispatch a goroutine to consume event from poll reader
for each client connection that is ready to read.
The maximum number of goroutine is defined in ServerOptions
maxGoroutineReader, which currently set to 1024.
|
|
The maxGoroutineUpgrader define maximum goroutines running at the same
time to handle client upgrade.
The new goroutine only dispatched when others are full, so it will
run incrementally not all at once.
Default to defServerMaxGoroutineUpgrader (128) if its not set.
|
|
The ReadWriteTimeout define the maximum duration the server wait when
receiving/sending packet from/to client before considering the
connection as broken.
Default read-write timeout is 30 seconds if not set.
This changes affect the exported function Send and Recv by adding
additional parameter timeout to both of them.
|
|
The maxBuffer increased from 1024 to 4096 bytes.
The reason that we use 1024 previously is related to MTU size and maximum
payload in TCP (although its higher, 1460 bytes).
The maxQueue increase from 128 to 4096.
|
|
Using global debug value for all packages turns out is not a good
idea.
|
|
|
|
Replace assignment from using ":=" to use variable declaration with
type.
Rationale: clarity and minimize duplicate temporary variables with the
same type.
|
|
Changes,
* Client: from 176 to 144 (-32 bytes)
* ClientManager: from 64 to 40 (-24 bytes)
* Request: from 88 to 72 (-16 bytes)
* Response: from 40 to 24 (-16 bytes)
* route: from 48 to 32 (-16 bytes)
* Server: from 72 to 64 (-8 bytes)
* ServerOptions: from 104 to 96 (s-8 bytes)
Plus other structs in the tests.
|
|
|
|
Previously, the RegisterTextHandler method return nil if method, target,
or handler parameter is not set. This may cause confusion and hard to
debug handler when no connection receive but the RegisterTextHandler
does not have any error.
|
|
Instead of accessing the ctx field directly, call the Context() method
to prevent data race.
|
|
Previously, the Options field is not exported to prevent user from
changing it once it set throught NewServer() function.
This changes export the Options field to allow user of Server access its
values. We can create a method on server to return read-only options,
but that will over complicated the Server API.
|
|
This is to fix Stop() method waiting for running channel to be consumed.
|
|
|
|
|
|
|
|
Previously, there is only one option for server, the port where it will
listen.
This changes add option to change the connect path (default to "/"
previously) and new path and handler for retrieving server status.
|
|
Requesting "GET /health" on WebSocket server will return HTTP status
code 204, which can be used for service health checking.
|
|
|
|
|
|
Previously, the Response in RouteHandler is passed in parameter, which
seems weird for handler.
This commit, move the Response from parameter to return values.
|
|
|
|
|
|
|
|
|
|
This is to prevent the handler change the ID of response.
|
|
By using libnet.Poll, websocket package now support both Linux and
Darwin/BSD.
|
|
The check for frames is already done in the above statement, where it
will remove the connection and continue the loop.
|
|
Use "fmt" package when printing debugging information, and "log" package
when printing error.
|
|
The Frame Pack method is only used internally, implementor should use
NewFrameXxx functions.
|
|
This is to minimize duplicate code on client and server.
|
|
The decision to randomize mask is now based on whether the maskKey length
is equal to 4 or not. If its 4 the maskKey will not be randomized.
|
|
Previously, we use two function to unpack frame: frameUnpack and
continueUnpack, both of this functions actually use the same logic.
This commit merge both functions into Frame's unpack() and which also
make handleChopped() to be unused on both server and client.
|
|
For control CLOSE frame, the frame's length, close code, and payload are
all related. For example, the length of 2 indicate that there is a close
code in payload.
This change only affect test when unpacking close frame, and does not
affect the result of autobahn test.
|
|
|
|
This is to minimize duplicate code on server's reader and when handling
chopped frame.
|
|
This is to minimize duplicate code on server's reader and handling
chopped frame.
|
|
The opcode type is required to create new frame and to get the opcode in
continous frames.
|
|
Some of the methods in ClientManager and Frames should be only accessed
by internal server, not by implementor.
|
|
By running the handler on separated routines, we can prevent the server
select to be blocked by reading or writing larger packet.
|
|
Connection without fragmentation with the first frame is CONT frame,
should be closed with bad-request (1002).
Connection with fragmentation but the next frame opcode is not CONT,
should be closed with bad-request (1002).
|
|
Another possibility is fragmented frames with one of the frame is
chopped and in the middle of it is a control FRAME. For example,
C> Frame{fin:false opcode:TEXT len:1024 payload:512}
C> payload:512 FRAME{fin:TRUE opcode:PING len:0}
C> Frame{fin:true opcode:0 len:1024 payload:1024}
|