<commit_before>package rhynock

import (
	"github.com/gorilla/websocket"
	"net/http"
	"strconv"
	"time"
	"math"
	"sync"
	"log"
)


// Some defaults for pinging
// Needs to be settable from outside
var (
	writeWait = 10 * time.Second
	pongWait = 60 * time.Second
	pingPeriod = (pongWait * 9) / 10
	maxMessageSize int64 = math.MaxInt64
)


// Conn encapsulates our websocket
type Conn struct {
	// Exported actual webscoket so can be messed with from outside
	Ws        *websocket.Conn
	Send      chan []byte
	Dst       BottleDst
	Quit      chan []byte
	valid     bool

	// Ping Calculation
	// TODO make sure pings pair off, right now really bad lagg would case ping ping pong to give a false ping value
	lastping  int64
	ping      int64
	pinglock  sync.Mutex
}


//
// Change global properties of rhynock
// Options are: writeWait, pongWait, pingPeriod, maxMessageSize
// Value is a string that will be parsed into the correct type.
// For writeWait, pongWait, and pingPeriod a duration string is expected, for maxMessageSize an int string.
//
func SetProperty(key, value string) {
	switch key {
	case "writeWait":
		val, err := time.ParseDuration(value)
		if err == nil {
			writeWait = val
		} else {
			log.Println(err)
		}
	case "pongWait":
		val, err := time.ParseDuration(value)
		if err == nil {
			pongWait = val
		} else {
			log.Println(err)
		}
	case "pingPeriod":
		val, err := time.ParseDuration(value)
		if err == nil {
			pingPeriod = val
		} else {
			log.Println(err)
		}
	case "maxMessageSize":<commit_msg>Accessor functions for the addresses remote and local<commit_after>package rhynock

import (
	"github.com/gorilla/websocket"
	"net/http"
	"strconv"
	"time"
	"math"
	"sync"
	"log"
)


// Some defaults for pinging
// Needs to be settable from outside
var (
	writeWait = 10 * time.Second
	pongWait = 60 * time.Second
	pingPeriod = (pongWait * 9) / 10
	maxMessageSize int64 = math.MaxInt64
)


// Conn encapsulates our websocket
type Conn struct {
	// Exported actual webscoket so can be messed with from outside
	Ws        *websocket.Conn
	Send      chan []byte
	Dst       BottleDst
	Quit      chan []byte
	valid     bool

	// Ping Calculation
	// TODO make sure pings pair off, right now really bad lagg would case ping ping pong to give a false ping value
	lastping  int64
	ping      int64
	pinglock  sync.Mutex
}


//
// Get remote address
//
func (c *Conn) RemoteAddr() string {
	return c.Ws.RemoteAddr()
}


//
// Get local address
//
func (c *Conn) LocalAddr() string {
	return c.Ws.LocalAddr()
}

//
// Change global properties of rhynock
// Options are: writeWait, pongWait, pingPeriod, maxMessageSize
// Value is a string that will be parsed into the correct type.
// For writeWait, pongWait, and pingPeriod a duration string is expected, for maxMessageSize an int string.
//
func SetProperty(key, value string) {
	switch key {
	case "writeWait":
		val, err := time.ParseDuration(value)
		if err == nil {
			writeWait = val
		} else {
			log.Println(err)
		}
	case "pongWait":
		val, err := time.ParseDuration(value)
		if err == nil {
			pongWait = val
		} else {
			log.Println(err)
		}
	case "pingPeriod":
		val, err := time.ParseDuration(value)
		if err == nil {
			pingPeriod = val
		} else {
			log.Println(err)
		}
	case "maxMessageSize":
{'fraction_non_alphanumeric': 0.09957238851557727, 'fraction_numerical': 0.00916310323762981, 'mean_word_length': 3.038224414303329, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '267096', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1105, 'n_words': 376}