eyego

package module
v0.0.0-...-e2dd8a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2016 License: BSD-3-Clause Imports: 22 Imported by: 0

README

EyeGo

Eyefi Upload Server written in Go.

  • Full support of photo & movie uploading
  • Processes files then moves them to target directory
  • Geotagging support via the Google Geolocation API (max. 100 requests / day)
  • BSD licensed

Requires a configuration file in JSON, using the following format:

{
    "target_dir":"/Users/jpg/Photos",
    "google_api_key":"XXX",
    "cards":[
        {
            "mac_address":"XXX",
            "upload_key":"XXX"
        }
    ]
}

Documentation

Index

Constants

View Source
const (

	// Types
	TypeReg           = '0'    // regular file
	TypeRegA          = '\x00' // regular file
	TypeLink          = '1'    // hard link
	TypeSymlink       = '2'    // symbolic link
	TypeChar          = '3'    // character device node
	TypeBlock         = '4'    // block device node
	TypeDir           = '5'    // directory
	TypeFifo          = '6'    // fifo node
	TypeCont          = '7'    // reserved
	TypeXHeader       = 'x'    // extended header
	TypeXGlobalHeader = 'g'    // global extended header
)

Variables

View Source
var (
	TRACE = LogLevel{/* contains filtered or unexported fields */}
	DEBUG = LogLevel{/* contains filtered or unexported fields */}
	INFO  = LogLevel{/* contains filtered or unexported fields */}
	WARN  = LogLevel{/* contains filtered or unexported fields */}
	ERROR = LogLevel{/* contains filtered or unexported fields */}
)
View Source
var (
	ErrHeader = errors.New("archive/tar: invalid tar header")
)
View Source
var (
	LOC_BASE_URL = "https://www.googleapis.com/geolocation/v1/geolocate"
)

Functions

func Abs

func Abs(i int) int

func Atoi

func Atoi(s string) (i int)

func ConfigFrom

func ConfigFrom(path string)

func CopyFile

func CopyFile(dst, src string) (int64, error)

func CreateSoap

func CreateSoap(body interface{}) string

func Debug

func Debug(s string, args ...interface{})

func DumpConfig

func DumpConfig(config EyegoConfig)

func EachLine

func EachLine(r io.Reader, f func(string) interface{}) (rv []interface{}, err error)

func GenerateSNonce

func GenerateSNonce() string

func Handler

func Handler(w http.ResponseWriter, r *http.Request)

func Info

func Info(s string, args ...interface{})

func Init

func Init(w io.Writer, _level LogLevel)

func LogError

func LogError(s string, args ...interface{})

func ParseSoap

func ParseSoap(s string, target interface{})

func SetConfig

func SetConfig(_config EyegoConfig)

func Trace

func Trace(s string, args ...interface{})

func Warn

func Warn(s string, args ...interface{})

func WriteGeotag

func WriteGeotag(mediaFile string, location LocationResult) string

func WriteSoap

func WriteSoap(body interface{}, writer io.Writer)

Types

type AccessPointSighting

type AccessPointSighting struct {
	MacAddress string
	SNR        int
	Data       int32
	Secs       int
	PowerSecs  int
}

type AccessPointSightingInfo

type AccessPointSightingInfo struct {
	MacAddress string `json:"macAddress"`
	Age        int    `json:"age"`
	SNR        int    `json:"signalToNoiseRatio"`
}

type BlockNotifyingReader

type BlockNotifyingReader struct {
	// contains filtered or unexported fields
}

func NewBlockNotifyingReader

func NewBlockNotifyingReader(_delegate io.Reader, _blockSize int, _notifier func([]byte)) BlockNotifyingReader

func (BlockNotifyingReader) Read

func (r BlockNotifyingReader) Read(p []byte) (n int, err error)

type Card

type Card struct {
	UploadKey  string `json:"upload_key"`
	MacAddress string `json:"mac_address"`
}

func GetCard

func GetCard(mac_address string) Card

func (Card) Credential

func (c Card) Credential(cnonce string) string

type ChecksumReader

type ChecksumReader struct {
	// contains filtered or unexported fields
}

func NewChecksumReader

func NewChecksumReader(r io.Reader) ChecksumReader

func (ChecksumReader) Checksum

func (cr ChecksumReader) Checksum(uploadKey string) string

func (ChecksumReader) Read

func (r ChecksumReader) Read(p []byte) (n int, err error)

type EyegoConfig

type EyegoConfig struct {
	TargetDir    string `json:"target_dir"`
	GoogleAPIKey string `json:"google_api_key"`
	Cards        []Card `json:"cards"`
}

func Config

func Config() EyegoConfig

type GetPhotoStatus

type GetPhotoStatus struct {
	Credential    string `xml:"credential"`
	MacAddress    string `xml:"macaddress"`
	Filename      string `xml:"filename"`
	FileSize      string `xml:"filesize"`
	FileSignature string `xml:"filesignature"`
	Flags         string `xml:"flags"`
}

type GetPhotoStatusResponse

type GetPhotoStatusResponse struct {
	FileID  string   `xml:"fileid"`
	Offset  string   `xml:"offset"`
	XMLName xml.Name `xml:"ns1:GetPhotoStatusResponse"`
}
type Header struct {
	Name       string    // name of header file entry
	Mode       int64     // permission and mode bits
	Uid        int       // user id of owner
	Gid        int       // group id of owner
	Size       int64     // length in bytes
	ModTime    time.Time // modified time
	Typeflag   byte      // type of header entry
	Linkname   string    // target name of link
	Uname      string    // user name of owner
	Gname      string    // group name of owner
	Devmajor   int64     // major number of character or block device
	Devminor   int64     // minor number of character or block device
	AccessTime time.Time // access time
	ChangeTime time.Time // status change time
}

A Header represents a single header in a tar archive. Some fields may not be populated.

type Location

type Location struct {
	Latitude  float64 `json:"lat"`
	Longitude float64 `json:"lng"`
}

type LocationResult

type LocationResult struct {
	Location Location `json:"location"`
	Accuracy float64  `json:"accuracy"`
}

func GPSCoordinates

func GPSCoordinates(aps []AccessPointSightingInfo) (lr LocationResult, err error)

type LogLevel

type LogLevel struct {
	// contains filtered or unexported fields
}

func LogLevelFromName

func LogLevelFromName(name string) LogLevel

type MarkLastPhotoInRoll

type MarkLastPhotoInRoll struct {
	MacAddress string `xml:"macaddress"`
	MergeDelta string `xml:"mergedelta"`
}

type MarkLastPhotoInRollResponse

type MarkLastPhotoInRollResponse struct {
	XMLName xml.Name `xml:"ns1:MarkLastPhotoInRollResponse"`
}

type NewPhoto

type NewPhoto struct {
	Filename  string
	PowerSecs int
	Secs      int
	Size      int
}

type ParsedLog

type ParsedLog struct {
	Cycles []PoweredCycle
}

func ParseLog

func ParseLog(log io.Reader) (p ParsedLog, err error)

func (ParsedLog) AccessPoints

func (p ParsedLog) AccessPoints(photoName string) []AccessPointSightingInfo

type PowerOn

type PowerOn struct{}

type PoweredCycle

type PoweredCycle struct {
	Photos       map[string][]NewPhoto
	AccessPoints map[string][]AccessPointSighting
}

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

A Reader provides sequential access to the contents of a tar archive. A tar archive consists of a sequence of files. The Next method advances to the next file in the archive (including the first), and then it can be treated as an io.Reader to access the file's data.

Example:

tr := tar.NewReader(r)
for {
	hdr, err := tr.Next()
	if err == io.EOF {
		// end of tar archive
		break
	}
	if err != nil {
		// handle error
	}
	io.Copy(data, tr)
}

func NewTarReader

func NewTarReader(r io.Reader) *Reader

NewReader creates a new Reader reading from r.

func (*Reader) Next

func (tr *Reader) Next() (*Header, error)

Next advances to the next entry in the tar archive.

func (*Reader) Read

func (tr *Reader) Read(b []byte) (n int, err error)

Read reads from the current entry in the tar archive. It returns 0, io.EOF when it reaches the end of that entry, until Next is called to advance to the next entry.

type SoapStartSession

type SoapStartSession struct {
	MacAddress            string `xml:"macaddress"`
	CNonce                string `xml:"cnonce"`
	TransferMode          string `xml:"transfermode"`
	TransferModeTimestamp string `xml:"transfermodetimestamp"`
}

type SoapStartSessionResponse

type SoapStartSessionResponse struct {
	Credential            string   `xml:"credential"`
	SNonce                string   `xml:"snonce"`
	TransferMode          string   `xml:"transfermode"`
	TransferModeTimestamp string   `xml:"transfermodetimestamp"`
	UpSyncAllowed         string   `xml:"upsyncallowed"`
	XMLName               xml.Name `xml:"ns1:StartSessionResponse"`
}

type UnknownLine

type UnknownLine struct {
	Content string
}

type UploadPhoto

type UploadPhoto struct {
	FileID        string `xml:"fileid"`
	MacAddress    string `xml:"macaddress"`
	Filename      string `xml:"filename"`
	FileSize      string `xml:"filesize"`
	FileSignature string `xml:"filesignature"`
	Encryption    string `xml:"encryption"`
	Flags         string `xml:"flags"`
}

type UploadPhotoResponse

type UploadPhotoResponse struct {
	Success string   `xml:"success"`
	XMLName xml.Name `xml:"ns1:UploadPhotoResponse"`
}

type WifiAccessPoints

type WifiAccessPoints struct {
	AccessPoints []AccessPointSightingInfo `json:"wifiAccessPoints"`
	ConsiderIp   bool                      `json:"considerIp"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL