Skip to content

Commit

Permalink
replace custom proxyAddr func with proxy_addr pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
v1rtl committed Mar 6, 2021
1 parent 39fbfaa commit c431cc2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 202 deletions.
1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { encodeUrl } from 'https://deno.land/x/encodeurl@1.0.0/mod.ts'
export { charset, contentType, lookup } from 'https://deno.land/x/media_types@v2.6.1/mod.ts'
export { default as rg } from 'https://esm.sh/regexparam'
export { forwarded } from 'https://deno.land/x/forwarded@v0.0.2/mod.ts'
export * from 'https://deno.land/x/proxy_addr@v0.0.0/mod.ts'
import type { ServerRequest as Req, Response as ServerResponse } from 'https://deno.land/std@0.88.0/http/server.ts'

interface Res extends ServerResponse {
Expand Down
4 changes: 1 addition & 3 deletions extensions/req/security.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { isIP } from '../../deps.ts'
import { Req } from '../../deps.ts'
import { isIP, Req, compile, all, proxyaddr } from '../../deps.ts'
import { Protocol } from '../../types.ts'
import { compile, proxyaddr, all } from '../../utils/proxyAddr.ts'

export const trustRemoteAddress = <Request extends Req = Req>(req: Request) => {
const val = (req.conn.remoteAddr as Deno.NetAddr).hostname
Expand Down
6 changes: 2 additions & 4 deletions utils/compileTrust.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compile } from './proxyAddr.ts'
import { compile } from '../deps.ts'

type TrustValue = ((...args: any[]) => any) | boolean | string | number | string[]

Expand All @@ -7,9 +7,7 @@ export function compileTrust(value: TrustValue) {

if (value === true) {
// Support plain true / false
return function () {
return true
}
return () => true
}

if (typeof value === 'number') {
Expand Down
195 changes: 0 additions & 195 deletions utils/proxyAddr.ts

This file was deleted.

0 comments on commit c431cc2

Please sign in to comment.