1. Go / Говнокод #26349

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    // GostServer is the type that contains all of the relevant information to set
    // up the GOST HTTP Server
    type GostServer struct {
    	host       string      // Hostname for example "localhost" or "192.168.1.14"
    	port       int         // Port number where you want to run your http server on
    	api        *models.API // SensorThings api to interact with from the HttpServer
    	https      bool
    	httpsCert  string
    	httpsKey   string
    	httpServer *http.Server
    }
    
    // CreateServer initialises a new GOST HTTPServer based on the given parameters
    func CreateServer(host string, port int, api *models.API, https bool, httpsCert, httpsKey string) Server {
    	setupLogger()
    	a := *api
    	router := CreateRouter(api)
    	return &GostServer{
    		host:      host,
    		port:      port,
    		api:       api,
    		https:     https,
    		httpsCert: httpsCert,
    		httpsKey:  httpsKey,
    		httpServer: &http.Server{
    			Addr:         fmt.Sprintf("%s:%s", host, strconv.Itoa(port)),
    			Handler:      PostProcessHandler(RequestErrorHandler(LowerCaseURI(router)), a.GetConfig().Server.ExternalURI),
    			ReadTimeout:  30 * time.Second,
    			WriteTimeout: 30 * time.Second,
    		},
    	}
    }
    
    // Start command to start the GOST HTTPServer
    func (s *GostServer) Start() {
    	t := "HTTP"
    	if s.https {
    		t = "HTTPS"
    	}
    
    	logger.Infof("Started GOST %v Server on %v:%v", t, s.host, s.port)
    
    	var err error
    	if s.https {
    		err = s.httpServer.ListenAndServeTLS(s.httpsCert, s.httpsKey)
    	} else {
    		err = s.httpServer.ListenAndServe()
    	}
    
    	if err != nil {
    		logger.Panicf("GOST server not properly stopped: %v", err)
    	}
    }
    
    // Stop command to stop the GOST HTTP server
    func (s *GostServer) Stop() {
    	if s.httpServer != nil {
    		logger.Info("Stopping HTTP(S) Server")
    		s.httpServer.Shutdown(context.Background())
    	}
    }

    Нашёл ГостСервер го

    https://github.com/gost/server/blob/master/http/gostserver.go

    gostinho, 13 Января 2020

    Комментарии (11)
  2. Go / Говнокод #25839

    0

    1. 1
    TOCTOU race condition in Docker allows root access to the filesystem of the host platform.[4]

    6a6yuH, 15 Сентября 2019

    Комментарии (52)
  3. Go / Говнокод #25729

    −1

    1. 1
    Ьут оказывается go есть

    TOPT, 22 Июля 2019

    Комментарии (20)