Browse Source

Acronym lints

pull/180/head
Kebert Xela 6 years ago
parent
commit
2d1cfb7d89
  1. 2
      README.md
  2. 14
      server.go
  3. 6
      server_test.go
  4. 10
      static/js/dropzone.js
  5. 4
      torrent.go
  6. 2
      torrent/torrent.go
  7. 4
      torrent_test.go
  8. 6
      upload.go

2
README.md

@ -74,7 +74,7 @@ The following storage backends are available:
- ```-keyfile path/to/your.key``` -- Path to the ssl key (required if you want to use the https server)
#### Use with http proxy
- ```-realIP``` -- let linx-server know you (nginx, etc) are providing the X-Real-IP and/or X-Forwarded-For headers.
- ```-RealIP``` -- let linx-server know you (nginx, etc) are providing the X-Real-IP and/or X-Forwarded-For headers.
#### Use with fastcgi
- ```-fastcgi``` -- serve through fastcgi

14
server.go

@ -13,7 +13,7 @@ import (
"strings"
"time"
"github.com/GeertJohan/go.rice"
rice "github.com/GeertJohan/go.rice"
"github.com/andreimarcu/linx-server/backends"
"github.com/andreimarcu/linx-server/backends/localfs"
"github.com/andreimarcu/linx-server/backends/s3"
@ -52,7 +52,7 @@ var Config struct {
xFrameOptions string
maxSize int64
maxExpiry uint64
realIp bool
RealIP bool
noLogs bool
allowHotlink bool
fastcgi bool
@ -83,7 +83,7 @@ func setup() *web.Mux {
// middleware
mux.Use(middleware.RequestID)
if Config.realIp {
if Config.RealIP {
mux.Use(middleware.RealIP)
}
@ -124,12 +124,12 @@ func setup() *web.Mux {
Config.siteURL = Config.siteURL + "/"
}
parsedUrl, err := url.Parse(Config.siteURL)
parsedURL, err := url.Parse(Config.siteURL)
if err != nil {
log.Fatal("Could not parse siteurl:", err)
}
Config.sitePath = parsedUrl.Path
Config.sitePath = parsedURL.Path
} else {
Config.sitePath = "/"
}
@ -222,7 +222,7 @@ func main() {
flag.StringVar(&Config.siteName, "sitename", "",
"name of the site")
flag.StringVar(&Config.siteURL, "siteurl", "",
"site base url (including trailing slash)")
"site base URL (including trailing slash)")
flag.StringVar(&Config.selifPath, "selifpath", "selif",
"path relative to site base url where files are accessed directly")
flag.Int64Var(&Config.maxSize, "maxsize", 4*1024*1024*1024,
@ -233,7 +233,7 @@ func main() {
"path to ssl certificate (for https)")
flag.StringVar(&Config.keyFile, "keyfile", "",
"path to ssl key (for https)")
flag.BoolVar(&Config.realIp, "realip", false,
flag.BoolVar(&Config.RealIP, "RealIP", false,
"use X-Real-IP/X-Forwarded-For headers as original host")
flag.BoolVar(&Config.fastcgi, "fastcgi", false,
"serve through fastcgi")

6
server_test.go

@ -19,7 +19,7 @@ import (
type RespOkJSON struct {
Filename string
Url string
URL string
Delete_Key string
Expiry string
Size string
@ -1277,7 +1277,7 @@ func TestPutAndGetCLI(t *testing.T) {
// request file without wget user agent
w = httptest.NewRecorder()
req, err = http.NewRequest("GET", myjson.Url, nil)
req, err = http.NewRequest("GET", myjson.URL, nil)
if err != nil {
t.Fatal(err)
}
@ -1290,7 +1290,7 @@ func TestPutAndGetCLI(t *testing.T) {
// request file with wget user agent
w = httptest.NewRecorder()
req, err = http.NewRequest("GET", myjson.Url, nil)
req, err = http.NewRequest("GET", myjson.URL, nil)
req.Header.Set("User-Agent", "wget")
if err != nil {
t.Fatal(err)

10
static/js/dropzone.js

@ -303,7 +303,7 @@
}
return this._updateMaxFilesReachedClass();
},
thumbnail: function(file, dataUrl) {
thumbnail: function(file, dataURL) {
var thumbnailElement, _i, _len, _ref;
if (file.previewElement) {
file.previewElement.classList.remove("dz-file-preview");
@ -311,7 +311,7 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
thumbnailElement = _ref[_i];
thumbnailElement.alt = file.name;
thumbnailElement.src = dataUrl;
thumbnailElement.src = dataURL;
}
return setTimeout(((function(_this) {
return function() {
@ -1061,13 +1061,13 @@
}
return;
}
return _this.createThumbnailFromUrl(file, fileReader.result, callback);
return _this.createThumbnailFromURL(file, fileReader.result, callback);
};
})(this);
return fileReader.readAsDataURL(file);
};
Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback) {
Dropzone.prototype.createThumbnailFromURL = function(file, imageURL, callback) {
var img;
img = document.createElement("img");
img.onload = (function(_this) {
@ -1097,7 +1097,7 @@
if (callback != null) {
img.onerror = callback;
}
return img.src = imageUrl;
return img.src = imageURL;
};
Dropzone.prototype.processQueue = function() {

4
torrent.go

@ -15,7 +15,7 @@ import (
)
func createTorrent(fileName string, f io.Reader, r *http.Request) ([]byte, error) {
url := getSiteURL(r) + Config.selifPath + fileName
URL := getSiteURL(r) + Config.selifPath + fileName
chunk := make([]byte, torrent.TORRENT_PIECE_LENGTH)
t := torrent.Torrent{
@ -24,7 +24,7 @@ func createTorrent(fileName string, f io.Reader, r *http.Request) ([]byte, error
PieceLength: torrent.TORRENT_PIECE_LENGTH,
Name: fileName,
},
UrlList: []string{url},
URLList: []string{URL},
}
for {

2
torrent/torrent.go

@ -18,7 +18,7 @@ type TorrentInfo struct {
type Torrent struct {
Encoding string `bencode:"encoding"`
Info TorrentInfo `bencode:"info"`
UrlList []string `bencode:"url-list"`
URLList []string `bencode:"url-list"`
}
func HashPiece(piece []byte) []byte {

4
torrent_test.go

@ -47,8 +47,8 @@ func TestCreateTorrent(t *testing.T) {
}
tracker := fmt.Sprintf("%s%s%s", Config.siteURL, Config.selifPath, fileName)
if decoded.UrlList[0] != tracker {
t.Fatalf("First entry in URL list was %s, expected %s", decoded.UrlList[0], tracker)
if decoded.URLList[0] != tracker {
t.Fatalf("First entry in URL list was %s, expected %s", decoded.URLList[0], tracker)
}
}

6
upload.go

@ -170,15 +170,15 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) {
}
upReq := UploadRequest{}
grabUrl, _ := url.Parse(r.FormValue("url"))
grabURL, _ := url.Parse(r.FormValue("url"))
resp, err := http.Get(grabUrl.String())
resp, err := http.Get(grabURL.String())
if err != nil {
oopsHandler(c, w, r, RespAUTO, "Could not retrieve URL")
return
}
upReq.filename = filepath.Base(grabUrl.Path)
upReq.filename = filepath.Base(grabURL.Path)
upReq.src = http.MaxBytesReader(w, resp.Body, Config.maxSize)
upReq.deleteKey = r.FormValue("deletekey")
upReq.randomBarename = r.FormValue("randomize") == "yes"

Loading…
Cancel
Save