conninfo.mjs 444 B

1234567891011121314151617
  1. // src/conninfo.ts
  2. var getConnInfo = (c) => {
  3. const bindings = c.env.server ? c.env.server : c.env;
  4. const address = bindings.incoming.socket.remoteAddress;
  5. const port = bindings.incoming.socket.remotePort;
  6. const family = bindings.incoming.socket.remoteFamily;
  7. return {
  8. remote: {
  9. address,
  10. port,
  11. addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
  12. }
  13. };
  14. };
  15. export {
  16. getConnInfo
  17. };