Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
726408c80f |
@@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||||
@@ -20,7 +21,15 @@ const (
|
|||||||
ClientTypeTor = "tor"
|
ClientTypeTor = "tor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// checks if strings contains http(s)://*.onion
|
||||||
|
var isOnion = regexp.MustCompile("^https?\\:\\/\\/[\\w\\-\\.]+\\.onion")
|
||||||
|
|
||||||
|
// GetClientForScheme returns correct client for url scheme.
|
||||||
|
// if tld is .onion, function will also return an onion client.
|
||||||
func GetClientForScheme(url *url.URL) (*http.Client, error) {
|
func GetClientForScheme(url *url.URL) (*http.Client, error) {
|
||||||
|
if isOnion.FindString(url.String()) != "" {
|
||||||
|
return GetClient(ClientTypeTor)
|
||||||
|
}
|
||||||
switch url.Scheme {
|
switch url.Scheme {
|
||||||
case "onion":
|
case "onion":
|
||||||
return GetClient(ClientTypeTor)
|
return GetClient(ClientTypeTor)
|
||||||
|
|||||||
Reference in New Issue
Block a user