summaryrefslogtreecommitdiffstats
path: root/conf/layer.conf
AgeCommit message (Collapse)AuthorFilesLines
2022-04-13Declare layer compatibility with kirkstoneScott Murray1-1/+1
For tracking upstream, we need to update the layer compatibility. Bug-AGL: SPEC-3819 Change-Id: I703d624b796164804315ceb14d5ccece89a274cf Signed-off-by: Scott Murray <scott.murray@konsulko.com> Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
2021-11-03Prepare master for new framework integrationJan-Simon Möller1-1/+1
During the last workshop the transition to the new framework was presented. This change essentially deprecates the SMACK-based application framework. To prepare the integration of it, we remove the deprecated components: - recipes-apis : all agl-service-* - recipes-demos: all demo apps but homescreen - non-essential configurations Todo: We need to bring-back the html5 image in a follow-up w/o ties into the old framework. v2: kept WAM + Chromium recipes for reference v3: rebased Bug-AGL: SPEC-4121 Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Change-Id: I58075f5f1e477106a1aad3d2171a0904bf0cb16e
2020-12-17SPEC-3723: restructure meta-agl-demoJan-Simon Moeller1-4/+7
All demo related components should be in here now. We keep the packagegroups on purpose for now to stay backward-compatible. v2: layer does pass yocto-check-layer, dependencies adapted v3: remove the dynamic-layer setup, use all-in-one approach v4: Fixed comments from Paul Barker. Tnx! v5: Removed wayland/weston/agl-compositor additions, except for demo specific weston-init bbappend Follow-up changes required later: - massaging packagegroups - scrub of recipes Bug-AGL: SPEC-3723 Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I47cefd8c23d46b2cdd063470e3f7d97d5ad952d8
2020-04-21Declare layer compatibility for dunfellScott Murray1-1/+1
For the upgrade to YP dunfell/3.1 we need to update the layer compatibility. Bug-AGL: SPEC-3302 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I7ca7a4ebba5bc723bf631b6908ee2f670c478103
2020-01-22Declare layer compatibility with zeusJan-Simon Möller1-1/+1
For the uprev to YP 3.0 zeus we need to update the layer compatibility. Change-Id: I1ed9fcd2134dc7a70855b8fed639a6e0f6d7f0f6 Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
2019-04-09Upgrade to thudScott Murray1-0/+2
Changes include: - Add LAYERSERIES_COMPAT definition to layer.conf - Replace libvcard recipe with bbappend now that a recipe is available in meta-qt5 - Add OECMAKE_GENERATOR = "Unix Makefiles" to libnaviapi-agl recipe for now to work around CMake+ninja issue - Add patch to navigation app to fix compilation against OpenSSL 1.1 - Remove libssp-dev from agl-demo-platform-crosssdk, upstream have removed it from non-mingw32 platform SDKs Known issues: - CMake+ninja issue in cmake-apps-module has been worked around with OECMAKE_GENERATOR Bug-AGL: SPEC-1837 Change-Id: I14c5355fb38d5eed064f154f889d61d8e46854b7 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
2015-08-22The starting point of layers for AGL Demo PlatformTadao Tanikawa1-0/+10
The `meta-agl-demo` is the Yocto layer for AGL Demo Platform of Automotive Grade Linux. This is starting point. Almost all packagegroups which should be defined in this layer are still empty (placeholder), so that curretly bitbake target `agl-demo-platform` is completely equal to `agl-image-ivi` in `meta-agl`. Change-Id: I6ce2c046cc8ce2dc5af2a8afe66e1f577dd884eb Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
1ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
package agent

import (
	"encoding/base64"
	"strconv"
	"time"

	"github.com/gin-gonic/gin"
	"github.com/googollee/go-socket.io"
	uuid "github.com/satori/go.uuid"
	"github.com/syncthing/syncthing/lib/sync"
)

const sessionCookieName = "xds-agent-sid"
const sessionHeaderName = "XDS-AGENT-SID"

const sessionMonitorTime = 10 // Time (in seconds) to schedule monitoring session tasks

const initSessionMaxAge = 10 // Initial session max age in seconds
const maxSessions = 100000   // Maximum number of sessions in sessMap map

const secureCookie = false // TODO: see https://github.com/astaxie/beego/blob/master/session/session.go#L218

// ClientSession contains the info of a user/client session
type ClientSession struct {
	ID       string
	WSID     string // only one WebSocket per client/session
	MaxAge   int64
	IOSocket *socketio.Socket

	// private
	expireAt time.Time
	useCount int64
}

// Sessions holds client sessions
type Sessions struct {
	*Context
	cookieMaxAge int64
	sessMap      map[string]ClientSession
	mutex        sync.Mutex
	stop         chan struct{} // signals intentional stop
}

// NewClientSessions .
func NewClientSessions(ctx *Context, cookieMaxAge string) *Sessions {
	ckMaxAge, err := strconv.ParseInt(cookieMaxAge, 10, 0)
	if err != nil {
		ckMaxAge = 0
	}
	s := Sessions{
		Context:      ctx,
		cookieMaxAge: ckMaxAge,
		sessMap:      make(map[string]ClientSession),
		mutex:        sync.NewMutex(),
		stop:         make(chan struct{}),
	}
	s.webServer.router.Use(s.Middleware())

	// Start monitoring of sessions Map (use to manage expiration and cleanup)
	go s.monitorSessMap()

	return &s
}

// Stop sessions management
func (s *Sessions) Stop() {
	close(s.stop)
}

// Middleware is used to managed session
func (s *Sessions) Middleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		// FIXME Add CSRF management

		// Get session
		sess := s.Get(c)
		if sess == nil {
			// Allocate a new session key and put in cookie
			sess = s.newSession("")
		} else {
			s.refresh(sess.ID)
		}

		// Set session in cookie and in header
		// Do not set Domain to localhost (http://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain)
		c.SetCookie(sessionCookieName, sess.ID, int(sess.MaxAge), "/", "",
			secureCookie, false)
		c.Header(sessionHeaderName, sess.ID)

		// Save session id in gin metadata
		c.Set(sessionCookieName, sess.ID)

		c.Next()
	}
}

// Get returns the client session for a specific ID
func (s *Sessions) Get(c *gin.Context) *ClientSession {
	var sid string

	// First get from gin metadata
	v, exist := c.Get(sessionCookieName)
	if v != nil {
		sid = v.(string)
	}

	// Then look in cookie
	if !exist || sid == "" {
		sid, _ = c.Cookie(sessionCookieName)
	}

	// Then look in Header
	if sid == "" {
		sid = c.Request.Header.Get(sessionCookieName)
	}
	if sid != "" {
		s.mutex.Lock()
		defer s.mutex.Unlock()
		if key, ok := s.sessMap[sid]; ok {
			// TODO: return a copy ???
			return &key
		}
	}
	return nil
}

// GetID returns the session or an empty string
func (s *Sessions) GetID(c *gin.Context) string {
	if sess := s.Get(c); sess != nil {
		return sess.ID
	}
	return ""
}

// IOSocketGet Get socketio definition from sid
func (s *Sessions) IOSocketGet(sid string) *socketio.Socket {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	sess, ok := s.sessMap[sid]
	if ok {
		return sess.IOSocket
	}
	return nil
}

// UpdateIOSocket updates the IO Socket definition for of a session
func (s *Sessions) UpdateIOSocket(sid string, so *socketio.Socket) error {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if _, ok := s.sessMap[sid]; ok {
		sess := s.sessMap[sid]
		if so == nil {
			// Could be the case when socketio is closed/disconnected
			sess.WSID = ""
		} else {
			sess.WSID = (*so).Id()
		}
		sess.IOSocket = so
		s.sessMap[sid] = sess
	}
	return nil
}

// newSession Allocate a new client session
func (s *Sessions) newSession(prefix string) *ClientSession {
	uuid := prefix + uuid.NewV4().String()
	id := base64.URLEncoding.EncodeToString([]byte(uuid))
	se := ClientSession{
		ID:       id,
		WSID:     "",
		MaxAge:   initSessionMaxAge,
		IOSocket: nil,
		expireAt: time.Now().Add(time.Duration(initSessionMaxAge) * time.Second),
		useCount: 0,
	}
	s.mutex.Lock()
	defer s.mutex.Unlock()

	s.sessMap[se.ID] = se

	s.Log.Debugf("NEW session (%d): %s", len(s.sessMap), id)
	return &se
}

// refresh Move this session ID to the head of the list
func (s *Sessions) refresh(sid string) {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	sess := s.sessMap[sid]
	sess.useCount++
	if sess.MaxAge < s.cookieMaxAge && sess.useCount > 1 {
		sess.MaxAge = s.cookieMaxAge
		sess.expireAt = time.Now().Add(time.Duration(sess.MaxAge) * time.Second)
	}

	// TODO - Add flood detection (like limit_req of nginx)
	// (delayed request when to much requests in a short period of time)

	s.sessMap[sid] = sess
}

func (s *Sessions) monitorSessMap() {
	for {
		select {
		case <-s.stop:
			s.Log.Debugln("Stop monitorSessMap")
			return
		case <-time.After(sessionMonitorTime * time.Second):
			if s.LogLevelSilly {
				s.Log.Debugf("Sessions Map size: %d", len(s.sessMap))
				s.Log.Debugf("Sessions Map : %v", s.sessMap)
			}

			if len(s.sessMap) > maxSessions {
				s.Log.Errorln("TOO MUCH sessions, cleanup old ones !")
			}

			s.mutex.Lock()
			for _, ss := range s.sessMap {
				if ss.expireAt.Sub(time.Now()) < 0 {
					if s.LogLevelSilly {
						s.Log.Debugf("Delete expired session id: %s", ss.ID)
					}
					delete(s.sessMap, ss.ID)
				}
			}
			s.mutex.Unlock()
		}
	}
}