Skip to content

Commit

Permalink
src: add Update(const sockaddr*) variant
Browse files Browse the repository at this point in the history
Signed-off-by: James M Snell <jasnell@gmail.com>
  • Loading branch information
jasnell committed Aug 21, 2020
1 parent 5d1cf62 commit 8ae503e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node_sockaddr-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ void SocketAddress::Update(uint8_t* data, size_t len) {
memcpy(&address_, data, len);
}

void SocketAddress::Update(const sockaddr* data, size_t len) {
CHECK_LE(len, sizeof(address_));
memcpy(&address_, data, len);
}

v8::Local<v8::Object> SocketAddress::ToJS(
Environment* env,
v8::Local<v8::Object> info) const {
Expand Down
1 change: 1 addition & 0 deletions src/node_sockaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class SocketAddress : public MemoryRetainer {
inline void set_flow_label(uint32_t label = 0);

inline void Update(uint8_t* data, size_t len);
inline void Update(const sockaddr* data, size_t len);

static SocketAddress FromSockName(const uv_udp_t& handle);
static SocketAddress FromSockName(const uv_tcp_t& handle);
Expand Down

0 comments on commit 8ae503e

Please sign in to comment.