summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-07-06Release share v0.28.0 (2021-07-06)v0.28.0Shulhan
=== Breaking changes * lib/ssh: rename method Get to ScpGet and Put to ScpPut This changes is to make clear that the methods to copy the files, either from local or from remote, is using the "scp" through exec package, not using the native SSH file transfer protocol. While at it, use consistent log prefix for error message. * ssh: rename the NewClient function to NewClientFromConfig This is to differentiate it with x/crypto ssh package that have the same function name. * ssh: move the config parser to subpackage "config" There are two reasons for moving to sub-package. First, the code for parsing the ssh_config(5) take almost 99% of the lines in the ssh package. Second, in case we want to submit the code to upstream, golang.org/x/crypto, we need the package to be independent, less external dependencies as possible. * http: remove the Memfs field from Server Now that Options field has been exported, we did not need to have duplicate Memfs, so this field is removed in favor of Options.Memfs. === Enhancements * websocket: export the Options field on the Server Previously, the Options field is not exported to prevent user from changing it once it set through 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. * http: export the Options field on the Server Previously, the Options field is not exported to prevent user from changing it once it set through 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. * websocket: store all the handshake headers to Handshake.Header Previously only non-required headers are stored in the Handshake Header field, while the required header value stored on their respective fields. This commit store all request header key and values into the Header field.
2021-07-05lib/ssh: rename method Get to ScpGet and Put to ScpPutShulhan
This changes is to make clear that the methods to copy the files, either from local or from remote, is using the "scp" through exec package, not using the native SSH file transfer protocol. While at it, use consistent log prefix for error message.
2021-07-05lib/ssh: embed the ssh.Client into Client instead of as fieldShulhan
This will allow seamless integration with the x/crypto/ssh Client type.
2021-07-05lib/ssh: rename the NewClient function to NewClientFromConfigShulhan
This is to differentiate it with x/crypto ssh package that have the same function name.
2021-07-05lib/ssh: move the config parser to subpackage "config"Shulhan
There are two reasons for moving to sub-package. First, the code for parsing the ssh_config(5) take almost 99% of the lines in the ssh package. Second, in case we want to submit the code to upstream, golang.org/x/crypto, we need the package to be independent, less external dependencies as possible.
2021-06-26http: remove the Memfs field from ServerShulhan
Now that Options field has been exported, we did not need to have duplicate Memfs, so this field is removed in favor of Options.Memfs.
2021-06-26go.mod: upgrade all dependenciesShulhan
2021-06-26http: simplify bytes to string conversion on unit testShulhan
2021-06-26websocket: export the Options field on the ServerShulhan
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.
2021-06-26http: export the Options field on the ServerShulhan
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.
2021-06-21websocket: store all the handshake headers to Handshake.HeaderShulhan
Previously only non-required headers are stored in the Handshake Header field, while the required header value stored on their respective fields. This commit store all request header key and values into the Header field.
2021-06-21websocket/testdata: fix the test server initializationShulhan
Since the commit 909a6c722d we change the server initialization using ServerOptions instead of port number only.
2021-06-05Release share v0.27.0 (2021-06-05)v0.27.0Shulhan
This release bring better functionalities, usability, and fixes for `xmlrpc` package. === Breaking changes * xmlrpc: change the Response to embed the errors.E The errors.E contains code and message that also implement wrapping and unwrapping error, so we can use the Response as error just like in http.EndpointResponse. * xmlrpc: write the XML header when marshaling request not on client Previously, the XML header is added when sending the request using client. This commit changes it to write the header when marshaling the Request instance. * xmlrpc: replace Value field for struct with map of string and value Previously, for param with type "struct" is represented by slice of Member{Name,Value}. This commit changes the Value field for "struct" to a map of string and value for easily access the struct's member, without looping. * xmlrpc: refactoring the parser for decoding XML-RPC request This changes, * method to parse XML-RPC request, * change the Member field Value type to pointer to Value, * change the Request field Params type to slice of pointer of Value, * change the Response field Param type to pointer to Value, * rename the Value fields from Members to StructMembers and Values to ArrayValues === New features * memfs: add function to Merge one or more instance of MemFS The Merge function merge one or more instance of MemFS into single MemFS instance. If there are two instance of Node that have the same path, the last instance will be ignored. * xmlrpc: add method to marshal Response * mlog: add function and method PrintStack The PrintStack function or method will writes to error writers the stack trace returned by debug.Stack. === Enhancements * http: add request type for XML Setting Endpoint's RequestType to RequestTypeXML will check the content type of HTTP request to match with "text/xml". === Bug fixes * memfs: set the field Parent on Node AddChild * xmlrpc: convert the uint8 and uint16 as type Integer, and Uint as Double Previously, uint8 and uint16 will be converted as Double, but those types are in range of four bytes so it can still be handled by int32. * xmlrpc: set client response IsFault when StatusCode >= 400 Previously, we set IsFault to true if the HTTP response code not equal to 200 only, which is not always correct. This commit changes it to check any status code that is greater or equal to 400. * memfs: fix test by checking multiple content-types On Arch Linux with Go tip, the content-type for JavaScript file is "text/javascript". While on Ubuntu with Go 1.16 the content-type for JavaScript file is "application/javascript".
2021-06-05xmlrpc: check for returned ok arguments on interface conversionShulhan
This is to make sure that the returned value is not ignored with "_". While at it, remove unused global constant `boolTrue`.
2021-06-03memfs: add function to Merge one or more instance of MemFSShulhan
The Merge function merge one or more instance of MemFS into single MemFS instance. If there are two instance of Node that have the same path, the last instance will be ignored.
2021-06-03memfs: set the field Parent on Node AddChildShulhan
2021-06-03memfs: update the package documentationShulhan
Explain the fields for Options on the first example and fix the field Root.
2021-05-25xmlrpc: convert the uint8 and uint16 as type Integer, and Uint as DoubleShulhan
Previously, uint8 and uint16 will be converted as Double, but those types are in range of four bytes so it can still be handled by int32.
2021-05-25xmlrpc: change the Response to embed the errors.EShulhan
The errors.E contains code and message that also implement wrapping and unwrapping error, so we can use the Response as error just like in http.EndpointResponse.
2021-05-19xmlrpc: marshal the struct value ordered by namesShulhan
This is to make the Request or Response format consistent and to make test working as expected.
2021-05-19xmlrpc: set client response IsFault when StatusCode >= 400Shulhan
Previously, we set IsFault to true if the HTTP response code not equal to 200 only, which is not always correct. This commit changes it to check any status code that is greater or equal to 400.
2021-05-19xmlrpc: add method to marshal ResponseShulhan
2021-05-19xmlrpc: write the XML header when marshaling request not on clientShulhan
Previously, the XML header is added when sending the request using client. This commit changes it to write the header when marshaling the Request instance.
2021-05-19xmlrpc: replace Value field for struct with map of string and valueShulhan
Previously, for param with type "struct" is represented by slice of Member{Name,Value}. This commit changes the Value field for "struct" to a map of string and value for easily access the struct's member, without looping.
2021-05-19xmlrpc: refactoring the parser for decoding XML-RPC requestShulhan
This changes, * method to parse XML-RPC request, * change the Member field Value type to pointer to Value, * change the Request field Params type to slice of pointer of Value, * change the Response field Param type to pointer to Value, * rename the Value fields from Members to StructMembers and Values to ArrayValues
2021-05-19http: add request type for XMLShulhan
Setting Endpoint's RequestType to RequestTypeXML will check the content type of HTTP request to match with "text/xml".
2021-05-04memfs: fix test by checking multiple content-typesShulhan
On Arch Linux with Go tip, the content-type for JavaScript file is "text/javascript". While on Ubuntu with Go 1.16 the content-type for JavaScript file is "application/javascript".
2021-05-04mlog: add function and method PrintStackShulhan
The PrintStack function or method will writes to error writers the stack trace returned by debug.Stack.
2021-05-04mlog: remove comment about adding new lineShulhan
In commit 25b6e78dd we add new line to error message, so this comment does not applicable anymore.
2021-05-03go.mod: update all dependenciesShulhan
2021-05-03Release share v0.26.0 (2021-05-03)v0.26.0Shulhan
=== New features * math/big: add method Add, IsLess, IsGreater, and Scan on Int The Add method simplify addition of one value to current Int. The IsLess and IsGreater method simplify comparing Int with any value. The Scan method allow the Int to be used on sql Scan(). * math/big: add method IsZero on Int The IsZero method will return true if the current i value is zero. * big: extends the standard big.Int The standard big.Int does not implement sql/driver.Valuer interface, which make it not usable when querying or doing update/insert with database. This commit extend the big.Int and simplify creating new Int from any values using NewInt(). Also, make it support marshal/unmarshal JSON === Enhancements * sql: make the column filename on table _migration as primary key This will allow deleting the record by filename instead of requiring all columns. * http: add the Total field to EndpointResponse The Total field contains the total number of all records, while the Count fields only contains the total number of records in Data. * http: add field Page to EndpointResponse The page field contains the requested page on current response. If page is from request then the offset will be set to page times limit. While at it, move the field comment to its declaration. * big: allow creating new Rat from uint64 and *big.Int * ssh: check for empty private key file on Get and Put If the private key file is empty, skip it for being added as parameter of scp command. This is to prevent warning message on user side. === Chores * memfs: update the test ContentType for JavaScript files The latest Go set the content type for JavaScript file as "text/javascript; charset=utf-8", not "application/javascript". * paseto: replace le64() function with binary.Write() The le64() return the string representation of uint64 in little endian, which is basically binary.Write with parameter output buffer, LittleEndian, and input value.
2021-04-27memfs: update the test ContentType for JavaScript filesShulhan
The latest Go set the content type for JavaScript file as "text/javascript; charset=utf-8", not "application/javascript".
2021-04-27sql: make the column filename on table _migration as primary keyShulhan
This will allow deleting the record by filename instead of requiring all columns.
2021-04-27big: add method Add, IsLess, IsGreater, and ScanShulhan
The Add method simplify addition of one value to current Int. The IsLess and IsGreater method simplify comparing Int with any value. The Scan method allow the Int to be used on sql Scan().
2021-04-23math/big: add method IsZero on IntShulhan
The IsZero method will return true if the current i value is zero.
2021-04-23math/big: use consistent receiver name for Int methodsShulhan
2021-04-23math/big: extend Int to support marshal/unmarshal JSONShulhan
2021-04-22paseto: replace le64() function with binary.Write()Shulhan
The le64() return the string representation of uint64 in little endian, which is basically binary.Write with parameter output buffer, LittleEndian, and input value.
2021-04-21http: add the Total field to EndpointResponseShulhan
The Total field contains the total number of all records, while the Count fields only contains the total number of records in Data.
2021-04-21big: extends the standard big.IntShulhan
The standard big.Int does not implement sql/driver.Valuer interface, which make it not usable when querying or doing update/insert with database. This commit extend the big.Int and simplify creating new Int from any values using NewInt().
2021-04-21http: add field Page to EndpointResponseShulhan
The page field contains the requested page or current response. If page is from request then the offset will be set to page times limit. While at it, move the field comment to its declaration.
2021-04-16big: allow creating new Rat from uint64 and *big.IntShulhan
2021-04-12.github: change the minimum Go version to 1.16Shulhan
2021-04-11ssh: check for empty private key file on Get and PutShulhan
If the private key file is empty, skip it for being added as parameter of scp command. This is to prevent warning message on user side.
2021-04-06Release share v0.25.1 (2021-04-06)v0.25.1Shulhan
Set the minimum Go version to 1.16 Commit 4cdd6b01c1 "http: add method to generate standard HTTP request on Client" use the io.NopCloser thats only available in Go 1.16. Either we move backward by replacing it with ioutil.NopCloser or we move forward by setting the minimum Go version to 1.16. We choose to move forward.
2021-04-06go.mod: set the minimum Go version to 1.16Shulhan
Commit 4cdd6b01c1 "http: add method to generate standard HTTP request on Client" use the io.NopCloser thats only available in Go 1.16. Either we move backward by replacing it with ioutil.NopCloser or we move forward by setting the minimum Go version to 1.16. We choose to move forward.
2021-04-06Release share v0.25.0v0.25.0Shulhan
=== Breaking changes * all: refactoring the test.Assert and test.AssertBench signature Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench. * all: refactoring http.Client methods signature Previously, parameters to method Delete, Get, Post, PostForm, PostFormData, PostJSON, Put, and PutJSON are in the following order: (headers, path, params) This is sometimes confusing. To make it better and works with format of HTTP request header, METHOD PATH HEADERS PARAMS we move the path to the first parameter and headers as the second parameter, so the call to client methods would be (path, headers, params) * http: remove parameter contentType on Client method Put Since one can set the Content-Type in parameter headers, this parameter is become redundant. === New features * http: add method to generate standard HTTP request on Client The GenerateHttpRequest method generate http.Request instance from method, path, requestType, headers, and params. For HTTP method GET, CONNECT, DELETE, HEAD, OPTIONS, or TRACE; the params value should be nil or url.Values. If its url.Values, then the params will be encoded as query parameters. For HTTP method is PATCH, POST, or PUT; the params will converted based on requestType rules below, * If requestType is RequestTypeQuery and params is url.Values it will be added as query parameters in the path. * If requestType is RequestTypeForm and params is url.Values it will be added as URL encoded in the body. * If requestType is RequestTypeMultipartForm and params type is map[string][]byte, then it will be converted as multipart form in the body. * If requestType is RequestTypeJSON and params is not nil, the params will be encoded as JSON in body. * ssh: ask for passphrase if private key is encrypted on generateSigners In case the private key defined in IdentityFile is encrypted, prompt for the passphrase on the screen and read it from stdin using terminal.ReadPassword(). This changes also remove call to generateSigners on postConfig(), instead invoke it from NewClient() to minimize multiple calls to generateSigners(). * ssh: use the SSH agent to authenticate on NewClient Previously, the client use the IdentityFile on ConfigSection to Authenticate with the remote SSH server. In case the IdentityFile is Encrypted with passphrase, each time NewClient is invoked it will ask For passphrase. To minimize inputing the passphrase, we check if current use run the SSH agent through SSH_AUTH_SOCK environment variable and use the agent To generate signers. This method need manual key added by user to SSH agent before calling NewClient to make it works. === Enhancements * xmlrpc: add debug statements to print request and response The debug level is set minimum to 3. If its set it will print the request and response to standard output.
2021-04-06websocket: suppress error on calling handleCloseShulhan
The handleClose is a function that will be called when client receive control CLOSE frame from server. Default handle is to response with control CLOSE frame with the same payload. This field is not exported, and only defined to allow testing.
2021-04-06ssh: use the SSH agent to authenticate on NewClientShulhan
Previously, the client use the IdentityFile on ConfigSection to authenticate with the remote SSH server. In case the IdentityFile is encrypted with passphrase, each time NewClient is invoked it will ask for passphrase. To minimize inputing the passphrase, we check if current use run the SSH agent through SSH_AUTH_SOCK environment variable and use the agent to generate signers. This method need manual key added by user to SSH agent before calling NewClient to make it works.
2021-04-05ssh: ask for passphrase if private key is encrypted on generateSignersShulhan
In case the private key defined in IdentityFile is encrypted, prompt for the passphrase on the screen and read it from stdin using term.ReadPassword(). This changes also remove call to generateSigners on postConfig(), instead invoke it from NewClient() to minimize multiple calls to generateSigners().