Skip to content

Commit

Permalink
Update codes
Browse files Browse the repository at this point in the history
Signed-off-by: HAHWUL <[email protected]>
  • Loading branch information
hahwul committed Oct 17, 2024
1 parent 23b0917 commit 602d497
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ steps:
# headers: "X-API-Key: 123444"
# worker_headers: "User-Agent: Deadfinder Bot"
# include30x: false
# user_agent: "Apple"
# proxy: "http://localhost:8070"

- name: Output Handling
run: echo '${{ steps.broken-link.outputs.output }}'
Expand Down Expand Up @@ -80,7 +82,11 @@ Options:
t, [--timeout=N] # Timeout in seconds
# Default: 10
o, [--output=OUTPUT] # File to write JSON result
H, [--headers=one two three] # Custom HTTP headers to send with request
H, [--headers=one two three] # Custom HTTP headers to send with initial request
[--worker-headers=one two three] # Custom HTTP headers to send with worker requests
[--user-agent=USER_AGENT] # User-Agent string to use for requests
# Default: Mozilla/5.0 (compatible; DeadFinder/1.5.0;)
p, [--proxy=PROXY] # Proxy server to use for requests
s, [--silent], [--no-silent] # Silent mode
v, [--verbose], [--no-verbose] # Verbose mode
```
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ runs:
- ${{ inputs.worker_headers}}
- ${{ inputs.verbose }}
- ${{ inputs.include30x }}
- ${{ inputs.user_agent }}
- ${{ inputs.proxy }}
4 changes: 4 additions & 0 deletions github-action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# %7 : worker headers
# $8 : verbose
# $9 : include30x
# $10 : user-agent
# $11 : proxy
# -------------

export df=/usr/local/bundle/gems/deadfinder-*/bin/deadfinder
Expand All @@ -20,6 +22,8 @@ cmd="$df $1 $2 -o /output.json"
[ "$5" = "true" ] && cmd="$cmd --silent"
[ "$8" = "true" ] && cmd="$cmd --verbose"
[ "$9" = "true" ] && cmd="$cmd --include30x"
[ -n "$10" ] && cmd="$cmd --user-agent=$10"
[ -n "$11" ] && cmd="$cmd --proxy=$11"

# Add headers if provided
if [ -n "$6" ]; then
Expand Down
16 changes: 15 additions & 1 deletion lib/deadfinder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,23 @@ def worker(_id, jobs, results, target, options)
uri = URI.parse(j)

# Create HTTP request with timeout and headers
http = Net::HTTP.new(uri.host, uri.port)
proxy_uri = URI.parse(options['proxy']) if options['proxy'] && !options['proxy'].empty?
http = if proxy_uri
Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
else
Net::HTTP.new(uri.host, uri.port)
end
http.use_ssl = (uri.scheme == 'https')
http.read_timeout = options['timeout'].to_i if options['timeout']

# Set SSL verification mode
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?

request = Net::HTTP::Get.new(uri.request_uri)

# Add User-Agent header
request['User-Agent'] = options['user_agent']

# Add worker headers if provided
options['worker_headers']&.each do |header|
key, value = header.split(':', 2)
Expand Down Expand Up @@ -189,6 +200,9 @@ class DeadFinder < Thor
class_option :headers, aliases: :H, default: [], type: :array,
desc: 'Custom HTTP headers to send with initial request'
class_option :worker_headers, default: [], type: :array, desc: 'Custom HTTP headers to send with worker requests'
class_option :user_agent, default: 'Mozilla/5.0 (compatible; DeadFinder/1.5.0;)', type: :string,
desc: 'User-Agent string to use for requests'
class_option :proxy, aliases: :p, default: '', type: :string, desc: 'Proxy server to use for requests'
class_option :silent, aliases: :s, default: false, type: :boolean, desc: 'Silent mode'
class_option :verbose, aliases: :v, default: false, type: :boolean, desc: 'Verbose mode'

Expand Down

0 comments on commit 602d497

Please sign in to comment.