peers propagation working fine, started to implement serverCA
jump to
@@ -6,3 +6,14 @@ - p2p
- blockchain - rsa - blind signature + + +--- + +Different nodes: +- peers +- serverCA + - Have the webapp to validate peers +- serverIDsigner + - The server where the user creates an account + - Also is the server that blind signs the Anonymous ID of the users
@@ -70,3 +70,4 @@ - REST:
- endpoint to get if the address is in the blockchain (to verify users) - parameters Date or LastUpdate on the structs needs to be updated values - implement rsa encryption between peers +- store blockchain in a .data file
@@ -26,15 +26,6 @@ var newPeer Peer
newPeer.IP = getIPFromConn(conn) newPeer.Port = getPortFromConn(conn) newPeer.Conn = conn - /* - //ask to the peer, for the peer ID - resp, err := http.Get("http://" + newPeer.IP + ":" + newPeer.Port) - check(err) - color.Red("-----") - fmt.Println(resp) - //newPeer.ID = resp - */ - //incomingPeersList.Peers = append(incomingPeersList.Peers, newPeer) incomingPeersList = appendPeerIfNoExist(incomingPeersList, newPeer) go handleConn(conn, newPeer) }@@ -48,7 +39,6 @@ log.Println("Error connecting to: " + peer.IP + ":" + peer.Port)
return } peer.Conn = conn - //outcomingPeersList.Peers = append(outcomingPeersList.Peers, peer) outcomingPeersList = appendPeerIfNoExist(outcomingPeersList, peer) go handleConn(conn, peer) }@@ -73,12 +63,7 @@ if err != nil {
log.Println(err) connRunning = false } else { - /* - fmt.Println(buffer) - fmt.Println(bytesRead) - */ var msg Msg - //color.Blue(string(buffer[0:bytesRead])) //msg = msg.createFromBytes([]byte(string(buffer[0:bytesRead]))) msg = msg.createFromBytes([]byte(newmsg)) messageHandler(connPeer, msg)@@ -87,7 +72,7 @@ }
//TODO add that if the peer closed is the p2p server, show a warning message at the peer log.Println("Peer: " + conn.RemoteAddr().String() + " connection closed") conn.Close() - //TODO delete the peer from the outcomingPeersList + //TODO delete the peer from the outcomingPeersList --> DONE deletePeerFromPeersList(connPeer, &outcomingPeersList) color.Yellow("peer deleted, current peerList:") printPeersList()
@@ -39,8 +39,7 @@ runningPeer.RESTPort = config.RESTPort
runningPeer.ID = hashPeer(runningPeer) runningPeer.Role = "client" - go runRestServer() - + //TODO clean and reorder the following lines (43 to 62) //read flags, to know if is runned as p2p server if len(os.Args) > 1 { if os.Args[1] == "server" {@@ -50,7 +49,19 @@ runningPeer.Port = config.ServerPort
runningPeer.ID = hashPeer(runningPeer) //runningPeer.ID = "0" } + if len(os.Args) > 3 { + config.Port = os.Args[2] + config.RESTPort = os.Args[3] + runningPeer.Port = os.Args[2] + runningPeer.RESTPort = os.Args[3] + if os.Args[1] == "server" { + runningPeer.Port = config.ServerPort + } + runningPeer.ID = hashPeer(runningPeer) + } } + + go runRestServer() thisPeerID = runningPeer.ID outcomingPeersList.PeerID = runningPeer.ID fmt.Println(runningPeer)@@ -67,9 +78,9 @@ serverPeer.IP = config.ServerIP
serverPeer.Port = config.ServerPort serverPeer.ID = hashPeer(serverPeer) serverPeer.Role = "server" + go acceptPeers(runningPeer) connectToPeer(serverPeer) reconstructBlockchainFromBlock("http://"+config.IP+":"+config.ServerRESTPort, blockchain.GenesisBlock) - go acceptPeers(runningPeer) } for running {
@@ -30,21 +30,24 @@ break
case "PeersList": color.Blue("newPeerslist") fmt.Println(msg.PeersList) + color.Red("PeersList") - //time.Sleep(1000 * time.Millisecond) updateNetworkPeersList(peer.Conn, msg.PeersList) propagatePeersList(peer) printPeersList() break case "PeersList_Response": - color.Blue("newPeerslist") + //for the moment is not beeing used + color.Blue("newPeerslist, from PeersList_Response") fmt.Println(msg.PeersList) + color.Red("PeersList_Response") - //time.Sleep(1000 * time.Millisecond) updateNetworkPeersList(peer.Conn, msg.PeersList) + propagatePeersList(peer) printPeersList() break case "Block": + //TODO check if the block is signed by an autorized emitter if !blockchain.blockExists(msg.Block) { blockchain.addBlock(msg.Block) propagateBlock(msg.Block)
@@ -23,6 +23,7 @@ a future option is to put:
type PeersList struct { Incoming PeersList Outcoming PeersList + Network PeersList } */@@ -75,7 +76,7 @@ }
} } -//send the outcomingPeersList to all the peers except the peer that has send the outcomingPeersList +//send the outcomingPeersList to all the peers except the peer p that has send the outcomingPeersList func propagatePeersList(p Peer) { for _, peer := range networkPeersList.Peers { if peer.Conn != nil {@@ -88,7 +89,16 @@ msgB := msg.toBytes()
_, err := peer.Conn.Write(msgB) check(err) } else { + /* + for the moment, this is not being called, due that in the IncomingPeersList, + there is no peer.ID, so in the comparation wih the peer that has send the + peersList, is comparing ID with "", so nevere enters this 'else' section + + maybe it's not needed. TODO check if it's needed the PeerList_Response + For the moment is working without it + */ //to the peer that has sent the peerList, we send our PeersList + var msg Msg msg.construct("PeersList_Response", "here my outcomingPeersList") msg.PeersList = outcomingPeersList@@ -100,6 +110,7 @@ } else {
//connect to peer if peer.ID != p.ID && peer.ID != runningPeer.ID { if peerIsInPeersList(peer, outcomingPeersList.Peers) == -1 { + color.Red("no connection, connecting to peer: " + peer.Port) connectToPeer(peer) } }
@@ -31,9 +31,6 @@ r := rand.Intn(max-min) + min
return r } func hashPeer(p Peer) string { - /*peerJson, err := json.Marshal(p) - check(err) - peerString := string(peerJson)*/ peerString := p.IP + ":" + p.Port h := sha256.New()
@@ -0,0 +1,29 @@
+cd peer +echo "compile Go" +echo "go build" +go build + +sleep 3 + +echo "peer server" +xterm -hold -e './peer server 3001 3002' & + +sleep 2 + +echo "register the first block" +curl -X POST http://127.0.0.1:3002/register -d '{"address": "firstaddress"}' + +sleep 2 + +echo "peer 1" +xterm -hold -e './peer client 3003 3004' & + +sleep 2 + +echo "peer 2" +xterm -hold -e './peer client 3005 3006' & + +sleep 2 + +echo "peer 3" +xterm -hold -e './peer client 3007 3008' &
@@ -0,0 +1,3 @@
+# serverCA + +peer server Certified Authority. The function of this server, is to validate the peers that will be authorized to add blocks to the blockchain
@@ -0,0 +1,8 @@
+{ + "ip": "127.0.0.1", + "port": "3030", + "serverip": "127.0.0.1", + "serverport": "3000", + "serverrestport": "3002", + "webserverport": "3080" +}
@@ -0,0 +1,15 @@
+package main + +import ( + "log" + "runtime" +) + +func check(err error) { + if err != nil { + _, fn, line, _ := runtime.Caller(1) + log.Println(line) + log.Println(fn) + log.Println(err) + } +}
@@ -0,0 +1,24 @@
+package main + +import ( + "io" + "log" + "os" + "strings" + "time" +) + +func savelog() { + timeS := time.Now().String() + _ = os.Mkdir("logs", os.ModePerm) + //next 3 lines are to avoid windows filesystem errors + timeS = strings.Replace(timeS, " ", "_", -1) + timeS = strings.Replace(timeS, ".", "-", -1) + timeS = strings.Replace(timeS, ":", "-", -1) + logFile, err := os.OpenFile("logs/log-"+timeS+".log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) + if err != nil { + panic(err) + } + mw := io.MultiWriter(os.Stdout, logFile) + log.SetOutput(mw) +}
@@ -0,0 +1,53 @@
+package main + +import ( + "log" + "net" + "net/http" + "time" + + "github.com/fatih/color" + "github.com/gorilla/handlers" +) + +type Peer struct { + ID string `json:"id"` //in the future, this will be the peer hash + IP string `json:"ip"` + Port string `json:"port"` + RESTPort string `json:"restport"` + Role string `json:"role"` //client or server + Conn net.Conn `json:"conn"` +} +type PeersList struct { + PeerID string + Peers []Peer `json:"peerslist"` + Date time.Time `json:"date"` +} + +var peersList PeersList + +func main() { + color.Blue("Starting CA") + + //read configuration file + readConfig("config.json") + + //run thw webserver + go webserver() + + //run API + log.Println("api server running") + log.Print("port: ") + log.Println(config.Port) + router := NewRouter() + headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"}) + originsOk := handlers.AllowedOrigins([]string{"*"}) + methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"}) + log.Fatal(http.ListenAndServe(":"+config.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router))) +} + +func webserver() { + log.Println("webserver in port " + config.WebServerPort) + http.Handle("/", http.FileServer(http.Dir("./webapp"))) + http.ListenAndServe(":"+config.WebServerPort, nil) +}
@@ -0,0 +1,16 @@
+package main + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func getPeers() { + res, err := http.Get("http://" + config.IP + ":" + config.ServerRESTPort + "/peers") + check(err) + body, err := ioutil.ReadAll(res.Body) + check(err) + err = json.Unmarshal(body, &peersList) + check(err) +}
@@ -0,0 +1,25 @@
+package main + +import ( + "encoding/json" + "io/ioutil" +) + +//Config reads the config +type Config struct { + IP string `json:"ip"` + Port string `json:"port"` + ServerIP string `json:"serverip"` + ServerPort string `json:"serverport"` + ServerRESTPort string `json:"serverrestport"` + WebServerPort string `json:"webserverport"` +} + +var config Config + +func readConfig(path string) { + file, err := ioutil.ReadFile(path) + check(err) + content := string(file) + json.Unmarshal([]byte(content), &config) +}
@@ -0,0 +1,47 @@
+package main + +import ( + "log" + "net/http" + "time" + + "github.com/gorilla/mux" +) + +type Route struct { + Name string + Method string + Pattern string + HandlerFunc http.HandlerFunc +} + +func Logger(inner http.Handler, name string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + + inner.ServeHTTP(w, r) + + log.Printf( + "%s\t%s\t%s\t%s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) +} +func NewRouter() *mux.Router { + router := mux.NewRouter().StrictSlash(true) + for _, route := range routes { + var handler http.Handler + handler = route.HandlerFunc + handler = Logger(handler, route.Name) + + router. + Methods(route.Method). + Path(route.Pattern). + Name(route.Name). + Handler(handler) + } + return router +}
@@ -0,0 +1,39 @@
+package main + +import ( + "encoding/json" + "fmt" + "net/http" +) + +type Routes []Route + +var routes = Routes{ + Route{ + "Index", + "GET", + "/", + Index, + }, + Route{ + "GetPeers", + "GET", + "/peers", + GetPeers, + }, +} + +type Address struct { + Address string `json:"address"` //the pubK of the user, to perform logins +} + +func Index(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "CA") +} +func GetPeers(w http.ResponseWriter, r *http.Request) { + getPeers() + + jResp, err := json.Marshal(peersList) + check(err) + fmt.Fprintln(w, string(jResp)) +}
@@ -0,0 +1,20 @@
+package main + +import ( + "log" + "net/http" + + "github.com/gorilla/handlers" +) + +func runRestServer() { + //run API + log.Println("server running") + log.Print("port: ") + log.Println(config.Port) + router := NewRouter() + headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"}) + originsOk := handlers.AllowedOrigins([]string{"*"}) + methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"}) + log.Fatal(http.ListenAndServe(":"+config.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router))) +}
@@ -0,0 +1,60 @@
+'use strict'; + +var urlapi = "http://localhost:3030/"; + +// Declare app level module which depends on views, and components +angular.module('webapp', [ + 'ngRoute', + 'ngMessages', + 'angularBootstrapMaterial', + 'toastr', + 'app.navbar', + 'app.main' +]). +config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { + $locationProvider.hashPrefix('!'); + + $routeProvider.otherwise({redirectTo: '/main'}); +}]) +.config(function(toastrConfig) { + angular.extend(toastrConfig, { + autoDismiss: false, + containerId: 'toast-container', + maxOpened: 0, + newestOnTop: true, + positionClass: 'toast-bottom-right', + preventDuplicates: false, + preventOpenDuplicates: false, + target: 'body' + }); +}) +.factory('httpInterceptor', function httpInterceptor () { + return { + request: function(config) { + return config; + }, + + requestError: function(config) { + return config; + }, + + response: function(res) { + return res; + }, + + responseError: function(res) { + return res; + } + }; +}) +.factory('api', function ($http) { + return { + init: function () { + /*$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('cr_webapp_token'); + $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('cr_webapp_token');*/ + } + }; +}) +.run(function (api) { + api.init(); +});
@@ -0,0 +1,17 @@
+{ + "name": "serverCA", + "description": "serverCA", + "version": "0.0.0", + "homepage": "", + "license": "MIT", + "private": true, + "dependencies": { + "angular": "^1.6.2", + "angular-route": "^1.6.1", + "angular-bootstrap-material": "abm#^0.1.4", + "angular-bootstrap": "^2.5.0", + "angular-messages": "^1.6.5", + "components-font-awesome": "^4.7.0", + "angular-toastr": "^2.1.1" + } +}
@@ -0,0 +1,556 @@
+/* red */ +.c_red50{ + background: #FFEBEE!important; + color: #000000!important; +} +.c_red100{ + background: #FFCDD2!important; + color: #000000!important; +} +.c_red200{ + background: #EF9A9A!important; + color: #000000!important; +} +.c_red300{ + background: #E57373!important; + color: #ffffff!important; +} +.c_red400{ + background: #EF5350!important; + color: #ffffff!important; +} +.c_red500{ + background: #F44336!important; + color: #ffffff!important; +} +.c_red600{ + background: #E53935!important; + color: #ffffff!important; +} +.c_red700{ + background: #D32F2F!important; + color: #ffffff!important; +} +.c_red800{ + background: #C62828!important; + color: #ffffff!important; +} +.c_red900{ + background: #B71C1C!important; + color: #ffffff!important; +} + +.ctext_red400{ + color: #EF5350!important; +} +.ctext_red500{ + color: #F44336!important; +} +.ctext_red600{ + color: #E53935!important; +} + +/* pink */ +.c_pink50{ + background: #FCE4EC!important; + color: #000000!important; +} +.c_pink100{ + background: #F8BBD0!important; + color: #000000!important; +} +.c_pink200{ + background: #F48FB1!important; + color: #000000!important; +} +.c_pink300{ + background: #F06292!important; + color: #ffffff!important; +} +.c_pink400{ + background: #EC407A!important; + color: #ffffff!important; +} +.c_pink500{ + background: #E91E63!important; + color: #ffffff!important; +} +.c_pink600{ + background: #D81B60!important; + color: #ffffff!important; +} +.c_pink700{ + background: #C2185B!important; + color: #ffffff!important; +} +.c_pink800{ + background: #AD1457!important; + color: #ffffff!important; +} +.c_pink900{ + background: #880E4F!important; + color: #ffffff!important; +} + +/* deepPurple */ +.c_deepPurple50{ + background: #EDE7F6!important; + color: #000000!important; +} +.c_deepPurple100{ + background: #D1C4E9!important; + color: #000000!important; +} +.c_deepPurple200{ + background: #B39DDB!important; + color: #000000!important; +} +.c_deepPurple300{ + background: #9575CD!important; + color: #ffffff!important; +} +.c_deepPurple400{ + background: #7E57C2!important; + color: #ffffff!important; +} +.c_deepPurple500{ + background: #673AB7!important; + color: #ffffff!important; +} +.c_deepPurple600{ + background: #5E35B1!important; + color: #ffffff!important; +} +.c_deepPurple700{ + background: #512DA8!important; + color: #ffffff!important; +} +.c_deepPurple800{ + background: #4527A0!important; + color: #ffffff!important; +} +.c_deepPurple900{ + background: #311B92!important; + color: #ffffff!important; +} +.ct_deepPurple300{ + color: #9575CD!important; +} +.c_deepPurpleG000to200{ + background: -moz-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right top, color-stop(0%, #ffffff), color-stop(100%, #D1C4E9))!important; /* safari4+,chrome */ + background: -webkit-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* opera 11.10+ */ + background: -ms-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* ie10+ */ + background: linear-gradient(90deg, #ffffff 0%, #D1C4E9 100%)!important; /* w3c */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#D1C4E9',GradientType=1 )!important; /* ie6-9 */ +} +.c_deepPurpleG500to300{ + background: -moz-linear-gradient(219deg, #9575CD 0%, #673AB7 100%)!important; /* ff3.6+ */ + background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, #673AB7), color-stop(100%, #9575CD))!important; /* safari4+,chrome */ + background: -webkit-linear-gradient(219deg, #9575CD 0%, #673AB7 100%)!important; /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(219deg, #9575CD 0%, #673AB7 100%)!important; /* opera 11.10+ */ + background: -ms-linear-gradient(219deg, #9575CD 0%, #673AB7 100%)!important; /* ie10+ */ + background: linear-gradient(231deg, #9575CD 0%, #673AB7 100%)!important; /* w3c */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#673AB7', endColorstr='#9575CD',GradientType=1 )!important; /* ie6-9 */ + color: #ffffff!important; +} +.c_deepPurpleG300to500{ + background: -moz-linear-gradient(42deg, #9575CD 0%, #673AB7 100%)!important; /* ff3.6+ */ + background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, #9575CD), color-stop(100%, #673AB7))!important; /* safari4+,chrome */ + background: -webkit-linear-gradient(42deg, #9575CD 0%, #673AB7 100%)!important; /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(42deg, #9575CD 0%, #673AB7 100%)!important; /* opera 11.10+ */ + background: -ms-linear-gradient(42deg, #9575CD 0%, #673AB7 100%)!important; /* ie10+ */ + background: linear-gradient(48deg, #9575CD 0%, #673AB7 100%)!important; /* w3c */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9575CD', endColorstr='#673AB7',GradientType=1 )!important; /* ie6-9 */ + color: #ffffff!important; +} + +/* indigo */ +.c_indigo50{ + background:#E8EAF6!important; + color: #000000!important; +} +.c_indigo100{ + background:#C5CAE9!important; + color: #000000!important; +} +.c_indigo200{ + background:#9FA8DA!important; + color: #000000!important; +} +.c_indigo300{ + background:#7986CB!important; + color: #ffffff!important; +} +.c_indigo400{ + background:#5C6BC0!important; + color: #ffffff!important; +} +.c_indigo500{ + background:#3F51B5!important; + color: #ffffff!important; +} +.c_indigo600{ + background:#3949AB!important; + color: #ffffff!important; +} +.c_indigo700{ + background:#303F9F!important; + color: #ffffff!important; +} +.c_indigo800{ + background:#283593!important; + color: #ffffff!important; +} +.c_indigo900{ + background:#1A237E!important; + color: #ffffff!important; +} + +.ctext_indigo500{ + color: #3F51B5!important; +} + +/* blue */ +.c_blue50{ + background: #E3F2FD!important; + color: #000000!important; +} +.c_blue100{ + background: #BBDEFB!important; + color: #000000!important; +} +.c_blue200{ + background: #90CAF9!important; + color: #000000!important; +} +.c_blue300{ + background: #64B5F6!important; + color: #ffffff!important; +} +.c_blue400{ + background: #42A5F5!important; + color: #ffffff!important; +} +.c_blue500{ + background: #2196F3!important; + color: #ffffff!important; +} +.c_blue600{ + background: #1E88E5!important; + color: #ffffff!important; +} +.c_blue700{ + background: #1976D2!important; + color: #ffffff!important; +} +.c_blue800{ + background: #1565C0!important; + color: #ffffff!important; +} +.c_blue900{ + background: #0D47A1!important; + color: #ffffff!important; +} + +.ct_blue300{ + color: #64B5F6; +} + +/* cyan */ +.c_cyan50{ + background: #E0F7FA!important; + color: #000000!important; +} +.c_cyan100{ + background: #B2EBF2!important; + color: #000000!important; +} +.c_cyan200{ + background: #80DEEA!important; + color: #000000!important; +} +.c_cyan300{ + background: #4DD0E1!important; + color: #ffffff!important; +} +.c_cyan400{ + background: #26C6DA!important; + color: #ffffff!important; +} +.c_cyan500{ + background: #00BCD4!important; + color: #ffffff!important; +} +.c_cyan600{ + background: #00ACC1!important; + color: #ffffff!important; +} +.c_cyan700{ + background: #0097A7!important; + color: #ffffff!important; +} +.c_cyan800{ + background: #00838F!important; + color: #ffffff!important; +} +.c_cyan900{ + background: #006064!important; + color: #ffffff!important; +} + +/* green */ +.c_green50{ + background: #E8F5E9!important; + color: #000000!important; +} +.c_green100{ + background: #C8E6C9!important; + color: #000000!important; +} +.c_green200{ + background: #A5D6A7!important; + color: #000000!important; +} +.c_green300{ + background: #81C784!important; + color: #ffffff!important; +} +.c_green400{ + background: #66BB6A!important; + color: #ffffff!important; +} +.c_green500{ + background: #4CAF50!important; + color: #ffffff!important; +} +.c_green600{ + background: #43A047!important; + color: #ffffff!important; +} +.c_green700{ + background: #388E3C!important; + color: #ffffff!important; +} +.c_green800{ + background: #2E7D32!important; + color: #ffffff!important; +} +.c_green900{ + background: #1B5E20!important; + color: #ffffff!important; +} + +.ct_green300{ + color: #81C784!important; +} +.c_green500to300{ + background: #4caf50; + background: -moz-linear-gradient(left, #4caf50 0%, #81c784 100%); + background: -webkit-linear-gradient(left, #4caf50 0%,#81c784 100%); + background: linear-gradient(to right, #4caf50 0%,#81c784 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4caf50', endColorstr='#81c784',GradientType=1 ); +} +/* yellow */ +.c_yellow50{ + background: #FFFDE7!important; + color: #000000!important; +} +.c_yellow100{ + background: #FFF9C4!important; + color: #000000!important; +} +.c_yellow200{ + background: #FFF59D!important; + color: #000000!important; +} +.c_yellow300{ + background: #FFF176!important; + color: #ffffff!important; +} +.c_yellow400{ + background: #FFEE58!important; + color: #ffffff!important; +} +.c_yellow500{ + background: #FFEB3B!important; + color: #ffffff!important; +} +.c_yellow600{ + background: #FDD835!important; + color: #ffffff!important; +} +.c_yellow700{ + background: #FBC02D!important; + color: #ffffff!important; +} +.c_yellow800{ + background: #F9A825!important; + color: #ffffff!important; +} +.c_yellow900{ + background: #F57F17!important; + color: #ffffff!important; +} + +/* orange */ +.c_orange50{ + background: #FFF3E0!important; + color: #000000!important; +} +.c_orange100{ + background: #FFE0B2!important; + color: #000000!important; +} +.c_orange200{ + background: #FFCC80!important; + color: #000000!important; +} +.c_orange300{ + background: #FFB74D!important; + color: #ffffff!important; +} +.c_orange400{ + background: #FFA726!important; + color: #ffffff!important; +} +.c_orange500{ + background: #FF9800!important; + color: #ffffff!important; +} +.c_orange600{ + background: #FB8C00!important; + color: #ffffff!important; +} +.c_orange700{ + background: #F57C00!important; + color: #ffffff!important; +} +.c_orange800{ + background: #EF6C00!important; + color: #ffffff!important; +} +.c_orange900{ + background: #E65100!important; + color: #ffffff!important; +} + +.ct_orange300{ + color: #FFB74D!important; +} + +/* grey */ +.c_grey50{ + background: #FAFAFA!important; + color: #000000!important; +} +.c_grey100{ + background: #F5F5F5!important; + color: #000000!important; +} +.c_grey200{ + background: #EEEEEE!important; + color: #000000!important; +} +.c_grey300{ + background: #E0E0E0!important; + color: #ffffff!important; +} +.c_grey400{ + background: #BDBDBD!important; + color: #ffffff!important; +} +.c_grey500{ + background: #9E9E9E!important; + color: #ffffff!important; +} +.c_grey600{ + background: #757575!important; + color: #ffffff!important; +} +.c_grey700{ + background: #616161!important; + color: #ffffff!important; +} +.c_grey800{ + background: #424242!important; + color: #ffffff!important; +} +.c_grey900{ + background: #212121!important; + color: #ffffff!important; +} + + + +/* blue grey */ +.c_blueGrey50{ + background: #ECEFF1!important; + color: #000000!important; +} +.c_blueGrey100{ + background: #CFD8DC!important; + color: #000000!important; +} +.c_blueGrey200{ + background: #B0BEC5!important; + color: #000000!important; +} +.c_blueGrey300{ + background: #90A4AE!important; + color: #ffffff!important; +} +.c_blueGrey400{ + background: #78909C!important; + color: #ffffff!important; +} +.c_blueGrey500{ + background: #607D8B!important; + color: #ffffff!important; +} +.c_blueGrey600{ + background: #546E7A!important; + color: #ffffff!important; +} +.c_blueGrey700{ + background: #455A64!important; + color: #ffffff!important; +} +.c_blueGrey800{ + background: #37474F!important; + color: #ffffff!important; +} +.c_blueGrey900{ + background: #263238!important; + color: #ffffff!important; +} +.c_blueGrey500to300{ + background: #607d8b; + background: -moz-linear-gradient(left, #607d8b 0%, #90a4ae 100%); + background: -webkit-linear-gradient(left, #607d8b 0%,#90a4ae 100%); + background: linear-gradient(to right, #607d8b 0%,#90a4ae 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#607d8b', endColorstr='#90a4ae',GradientType=1 ); +} + +.ctext_blueGrey500{ + color: #607D8B!important; +} + +.c_blueGradient1{ + background: #2d4a56!important; + background: -moz-linear-gradient(left, #2d4a56 0%, #1c2b36 100%)!important; + background: -webkit-linear-gradient(left, #2d4a56 0%,#1c2b36 100%)!important; + background: linear-gradient(to right, #2d4a56 0%,#1c2b36 100%)!important; + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d4a56', endColorstr='#1c2b36',GradientType=1 )!important; + + color: rgba(255,255,255,0.9)!important; +} +.c_blue2{ + background: rgb(28,43,54)!important; + color: rgba(255,255,255,0.8)!important; +} + +.cf_green2{ + color: rgb(32,158,145)!important; +}
@@ -0,0 +1,65 @@
+<!DOCTYPE html> +<html> + +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>serverCA</title> + <link rel="icon" type="image/png" href="img/logo.png"> + + <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans:400,700'> + <!-- Material Design fonts --> + <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700"> + <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons"> + + <link rel="stylesheet" href="bower_components/components-font-awesome/css/font-awesome.min.css"> + + + <link href="css/style.css" rel="stylesheet"> + <link href="css/colors.css" rel="stylesheet"> + + <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above + <link href="css/ionic.app.css" rel="stylesheet"> + --> + +</head> + +<body ng-app="webapp"> + <div ng-include="'views/navbar.html'"></div> + <br><br><br><br><br> + <div ng-view></div> + + + + <!-- Angular js --> + <script src="bower_components/angular/angular.js"></script> + <script src="bower_components/angular-route/angular-route.js"></script> + <script src="bower_components/angular-messages/angular-messages.js"></script> + + <!-- Bootstrap --> + <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> + <!-- Bootstrap Material Design --> + <link rel="stylesheet" href="bower_components/bootstrap-material-design/dist/css/bootstrap-material-design.css"> + <link rel="stylesheet" href="bower_components/bootstrap-material-design/dist/css/ripples.css"> + + <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> + <script src="bower_components/angular-bootstrap-material/dist/angular-bootstrap-material.js"></script> + <!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons"> + <link rel="stylesheet" href="https://unpkg.com/bootstrap-material-design@4.0.0-beta.4/dist/css/bootstrap-material-design.min.css" integrity="sha384-R80DC0KVBO4GSTw+wZ5x2zn2pu4POSErBkf8/fSFhPXHxvHJydT0CSgAP2Yo2r4I" crossorigin="anonymous"> +--> + <!-- jQuery for Bootstrap --> + <script src="bower_components/jquery/dist/jquery.min.js"></script> + + <!-- toastr --> + <link rel="stylesheet" type="text/css" href="bower_components/angular-toastr/dist/angular-toastr.css" /> + <script type="text/javascript" src="bower_components/angular-toastr/dist/angular-toastr.tpls.js"></script> + + + + <!-- app's js --> + <script src="app.js"></script> + <script src="views/navbar.js"></script> + <script src="views/main/main.js"></script> +</body> + +</html>
@@ -0,0 +1,21 @@
+{ + "name": "serverCA", + "private": true, + "version": "0.0.0", + "description": "serverCA", + "repository": "", + "license": "MIT", + "devDependencies": { + "bower": "^1.7.7", + "http-server": "^0.9.0" + }, + "scripts": { + "postinstall": "bower install --allow-root", + "prestart": "npm install", + "start": "http-server -p 8080 -c-1 ./" + }, + "dependencies": { + "connect": "latest", + "serve-static": "latest" + } +}
@@ -0,0 +1,19 @@
+<div class="container"> + <div class="row"> + <div class="col-md-3"> + </div> + <div class="col-md-6"> + <div class="card"> + {{peerslist.PeerID}} + <div class="card-body" style="max-height: 500px; overflow-y:scroll;"> + <div ng-repeat="peer in peerslist.peerslist"> + <b>{{peer.id}}</b> - {{peer.role}} + <br> + - {{peer.ip}}:{{peer.port}}, {{peer.restport}} + <hr> + </div> + </div> + </div> + </div> + </div> +</div>
@@ -0,0 +1,22 @@
+'use strict'; + +angular.module('app.main', ['ngRoute']) + + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/main', { + templateUrl: 'views/main/main.html', + controller: 'MainCtrl' + }); + }]) + + .controller('MainCtrl', function($scope, $http) { + $scope.peerslist = {}; + $http.get(urlapi + 'peers') + .then(function(data, status, headers, config) { + console.log('data success'); + console.log(data.data); + $scope.peerslist = data.data; + }, function(data, status, headers, config) { + console.log('data error'); + }); + });