Skip to content

Commit

Permalink
Merge pull request #151 from NodeFactoryIo/mpetrun5/enable-origin-and…
Browse files Browse the repository at this point in the history
…-cors

Enable origin and cors
  • Loading branch information
mpetrunic committed Dec 10, 2020
2 parents eea5915 + b66092f commit cce3ec7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.3.0
version=0.3.1
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD))

[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.1...HEAD)

## [v0.3.1]((https://github.com/NodeFactoryIo/vedran/tree/v0.3.1))

### Added

### Fix
- Enable CORS and set upgrader CheckOrigin to true [\#149](https://github.com/NodeFactoryIo/vedran/pull/149) ([mpetrun5](https://github.com/mpetrun5))

### Changed

[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.0...HEAD)
## [v0.3.0]((https://github.com/NodeFactoryIo/vedran/tree/v0.3.0))

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
vedran:
command: start --auth-secret=test-secret --log-level debug --public-ip vedran --server-port 4000 --private-key ${VEDRAN_LB_PK:-0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a} --payout-interval 1 --payout-reward ${VEDRAN_LB_REWARD_POOL:-10}
image: nodefactory/vedran:v0.3.0
image: nodefactory/vedran:v0.3.1
ports:
- "4000:4000"
container_name: "vedran"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/ethereum/go-ethereum v1.9.24
github.com/golang/gddo v0.0.0-20200831202555-721e228c7686
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.1
github.com/gosuri/uitable v0.0.4
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/ethereum/go-ethereum v1.9.24 h1:6AK+ORt3EMDO+FTjzXy/AQwHMbu52J2nYHIjy
github.com/ethereum/go-ethereum v1.9.24/go.mod h1:JIfVb6esrqALTExdz9hRYvrP0xBDf6wCncIu1hNwHpM=
github.com/fatih/color v1.3.0 h1:YehCCcyeQ6Km0D6+IapqPinWBK6y+0eB5umvZXK9WPs=
github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand Down Expand Up @@ -135,6 +137,8 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
Expand Down
6 changes: 5 additions & 1 deletion internal/controllers/ws.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package controllers

import (
"net/http"

"github.com/NodeFactoryIo/vedran/internal/configuration"
"github.com/NodeFactoryIo/vedran/internal/ws"
"github.com/gorilla/websocket"
log "github.com/sirupsen/logrus"
"net/http"
)

var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true
},
}

func (c ApiController) WSHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
15 changes: 11 additions & 4 deletions internal/loadbalancer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package loadbalancer

import (
"fmt"
"net/http"
"time"

"github.com/NodeFactoryIo/vedran/internal/actions"
"github.com/NodeFactoryIo/vedran/internal/auth"
"github.com/NodeFactoryIo/vedran/internal/configuration"
Expand All @@ -13,9 +16,8 @@ import (
schedulepayout "github.com/NodeFactoryIo/vedran/internal/schedule/payout"
"github.com/NodeFactoryIo/vedran/internal/schedule/penalize"
"github.com/asdine/storm/v3"
"github.com/gorilla/handlers"
log "github.com/sirupsen/logrus"
"net/http"
"time"
)

func StartLoadBalancerServer(
Expand Down Expand Up @@ -94,9 +96,14 @@ func StartLoadBalancerServer(
)
r := router.CreateNewApiRouter(apiController)
if props.CertFile != "" {
err = http.ListenAndServeTLS(fmt.Sprintf(":%d", props.Port), props.CertFile, props.KeyFile, r)
err = http.ListenAndServeTLS(
fmt.Sprintf(":%d", props.Port),
props.CertFile,
props.KeyFile,
handlers.CORS()(r),
)
} else {
err = http.ListenAndServe(fmt.Sprintf(":%d", props.Port), r)
err = http.ListenAndServe(fmt.Sprintf(":%d", props.Port), handlers.CORS()(r))
}
if err != nil {
log.Error(err)
Expand Down

0 comments on commit cce3ec7

Please sign in to comment.