Compare commits

..

10 Commits

Author SHA1 Message Date
Melvin Lammerts
256a0598d9 Refactor 2023-03-22 18:37:16 +01:00
Melvin
00736d5415 Update README.md 2023-03-22 18:20:17 +01:00
Melvin
f2e7d3a9ad Update README.md 2022-08-21 21:09:49 +02:00
Melvin
5cd5775161 Create LICENSE.md 2022-08-21 21:01:26 +02:00
Melvin Lammerts
b9972468c8 Merge branch 'main' of https://github.com/melvinsh/unhttpx 2022-08-21 20:58:35 +02:00
Melvin Lammerts
75d8c776f2 Better error handling 2022-08-21 20:58:33 +02:00
Melvin
e04dd39969 Update README.md 2022-08-21 20:50:07 +02:00
Melvin
515e0f3add Update README.md 2022-08-21 20:46:29 +02:00
Melvin
46ae2cafab Update README.md 2022-08-21 20:46:13 +02:00
Melvin
ed153442dd Update README.md 2022-08-21 20:29:03 +02:00
3 changed files with 48 additions and 24 deletions

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 ProjectDiscovery, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,4 +1,22 @@
# unhttpx # unhttpx
unhttpx is not a fast and multi-purpose HTTP toolkit that allows running multiple probes using the retryablehttp library. In fact, it does the exact opposite.
**TL;DR: turns a list of URLs into hostnames.** [![Go Reference](https://pkg.go.dev/badge/github.com/melvinsh/unhttpx.svg)](https://pkg.go.dev/github.com/melvinsh/unhttpx)
Turns a list of URLs into hostnames.
## Installation
``` bash
go install -v github.com/melvinsh/unhttpx@latest
```
## Usage
``` bash
$ echo "https://google.com/yo" | unhttpx
google.com
$ cat urls.txt | unhttpx
hackerone.com
zerocopter.com
```

29
main.go
View File

@@ -3,39 +3,24 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"net/url" "net/url"
"os" "os"
) )
func main() { func main() {
var urls []string
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() { for scanner.Scan() {
u := scanner.Text() inputURL := scanner.Text()
parsedURL, err := url.Parse(inputURL)
if u != "" { if err != nil {
urls = append(urls, u) fmt.Fprintf(os.Stderr, "Error parsing URL: %v\n", err)
continue
} }
fmt.Println(parsedURL.Host)
} }
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
log.Println(err) fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err)
}
for _, url := range urls {
fmt.Println(host(url))
} }
} }
func host(u string) string {
parsed, err := url.Parse(u)
if err != nil {
return u
}
return parsed.Host
}