Skip to content
Permalink
Browse files

Add noaa-proxy

  • Loading branch information...
frioux committed Feb 23, 2019
1 parent c2d56c0 commit 11fc9eb575494718e87042064079c084e335acf2
Showing with 47 additions and 0 deletions.
  1. +18 −0 README.mdwn
  2. +2 −0 cmd/leatherman/leatherman.go
  3. +27 −0 internal/tool/noaa/noaa.go
@@ -172,6 +172,24 @@ Little tool for generating bcrypt hashes.
Creates time series data by counting lines and grouping them by a given date
format.

### `noaa-proxy`

Creates a proxy for https://tgftp.nws.noaa.gov, but http, and listening on 9090.
This is because Ubuntu 18.04 ships with [taffybar]() 0.4.6, which only supports
http for the weather widgets and has hardcoded URLs.

To install, add this line to your hosts file:

```
127.0.0.1 tgftp.nws.noaa.gov
```

And run this iptables command:

```
iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 9090
```

### `minotaur`

```bash
@@ -24,6 +24,7 @@ import (
"github.com/frioux/leatherman/internal/tool/groupbydate"
"github.com/frioux/leatherman/internal/tool/minotaur"
"github.com/frioux/leatherman/internal/tool/netrcpassword"
"github.com/frioux/leatherman/internal/tool/noaa"
"github.com/frioux/leatherman/internal/tool/pomotimer"
"github.com/frioux/leatherman/internal/tool/prependemojihist"
"github.com/frioux/leatherman/internal/tool/replaceunzip"
@@ -63,6 +64,7 @@ func main() {
"gen-pass": genpass.Run,
"group-by-date": groupbydate.Run,
"netrc-password": netrcpassword.Run,
"noaa-proxy": noaa.Proxy,
"pomotimer": pomotimer.Run,
"prepend-emoji-hist": prependemojihist.Run,
"minotaur": minotaur.Run,
@@ -0,0 +1,27 @@
package noaa

import (
"io"
"net/http"
"net/http/httputil"
"net/url"
)

var upstream *url.URL

func init() {
// Manually resolved CNAME of tgftp.nws.noaa.gov
u, err := url.Parse("https://tgftp.cp.ncep.noaa.gov")
if err != nil {
panic("Couldn't parse url: " + err.Error())
}
upstream = u
}

// Proxy starts a proxy that can pretend to be the old noaa on http while
// actually proxying to noaa on https.
func Proxy(_ []string, _ io.Reader) error {
http.Handle("/", httputil.NewSingleHostReverseProxy(upstream))

return http.ListenAndServe(":9090", nil)
}

0 comments on commit 11fc9eb

Please sign in to comment.
You can’t perform that action at this time.