-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from Impa10r/v1.3.3
v1.3.3
- Loading branch information
Showing
21 changed files
with
570 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
push.sh | ||
cmd/psweb/__debug_bin* | ||
.vscode | ||
.vscode | ||
.vscode/launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package internet | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"net/url" | ||
"time" | ||
|
||
"peerswap-web/cmd/psweb/config" | ||
|
||
"golang.org/x/net/proxy" | ||
) | ||
|
||
// configures an http client with an optional Tor proxy | ||
func GetHttpClient(useProxy bool) *http.Client { | ||
var httpClient *http.Client | ||
|
||
if useProxy && config.Config.ProxyURL != "" { | ||
p, err := url.Parse(config.Config.ProxyURL) | ||
if err != nil { | ||
log.Println("Mempool getHttpClient:", err) | ||
return nil | ||
} | ||
dialer, err := proxy.SOCKS5("tcp", p.Host, nil, proxy.Direct) | ||
if err != nil { | ||
log.Println("Mempool getHttpClient:", err) | ||
return nil | ||
} | ||
httpClient = &http.Client{ | ||
Transport: &http.Transport{ | ||
Dial: dialer.Dial, | ||
}, | ||
Timeout: 5 * time.Second, | ||
} | ||
} else { | ||
httpClient = &http.Client{ | ||
Timeout: 5 * time.Second, | ||
} | ||
} | ||
return httpClient | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package internet | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// fetch the latest tag of PeerSwap Web from github.com | ||
func GetLatestTag() string { | ||
|
||
url := "http://api.github.com/repos/impa10r/peerswap-web/tags" | ||
|
||
req, err := http.NewRequest("GET", url, nil) | ||
if err != nil { | ||
log.Println("Error creating request:", err) | ||
return "" | ||
} | ||
|
||
req.Header.Set("Accept", "application/vnd.github.v3+json") | ||
|
||
client := GetHttpClient(true) | ||
resp, err := client.Do(req) | ||
if err != nil { | ||
log.Println("Error making request:", err) | ||
return "" | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
log.Println("Failed to fetch tags. Status code:", resp.StatusCode) | ||
return "" | ||
} | ||
|
||
var tags []map[string]interface{} | ||
err = json.NewDecoder(resp.Body).Decode(&tags) | ||
if err != nil { | ||
log.Println("Error decoding JSON:", err) | ||
return "" | ||
} | ||
|
||
if len(tags) > 0 { | ||
latestTag := tags[0]["name"].(string) | ||
return latestTag | ||
} else { | ||
log.Println("No tags found in the repository.") | ||
return "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.