pynezzentials

package module
v0.0.0-...-700a36e Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 2 Imported by: 0

README

Pynezzentials

GitHub go.mod Go version Go Report Card License

Pynezzentials is a Go package that provides some utilities for my personal projects. It is not intended to be a general-purpose library, but it may be useful for some people.

Features

  • cryptoutils: A set of utilities for encrypting and decrypting data.
  • fsUtils: A set of utilities for working with files.
  • ansi: A set of utilities for working with ANSI escape codes.

Installation

To install Pynezzentials, run:

go get -u github.com/pynezz/pynezzentials

Usage

package main

import (
    "fmt"
    utils "github.com/pynezz/pynezzentials"
)

func main() {
    fmt.Println(utils.Bold("Hello, world!"))
}

IPC

UNIX Domain sockets inter process communication (IPC) is a mechanism for exchanging data between processes running on the same host operating system. Pynezzentials provides a simple way to create a server and client for IPC.

Server
package main

import (
    "fmt"
    "github.com/pynezz/pynezzentials/ipc"
)

func main() {
    server := ipc.NewIPCServer("servername", [4]byte{0, 0, 0, 1})  // Identifier for the server

    server.LoadModules("config.txt")

    server.Listen(func(data []byte) []byte {
        fmt.Println("Received data:", string(data))
        return []byte("Hello, client!")
    })
}
Client
package main

import (
    "fmt"
    "github.com/pynezz/pynezzentials/ipc"
)

func main() {
    client := ipc.NewIPCClient("client1", [4]byte{0, 0, 0, 1})   // Identifier must match the server's identifier
    err := client.Connect()
    if err != {
        fmt.Println("Error:", err)
    }

    msg := client.CreateGenericReq([]byte("Hello, server!"), ipc.MSG_MSG, icp.DATA_JSON)

    response, err = client.SendIPCMessage(msg)
    if err != nil {
        fmt.Println("Error:", err)
    } else {
        fmt.Println("Received response:", string(response))
    }
}

License

LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeToUnixTimestamp

func TimeToUnixTimestamp(t time.Time) int64

TimeToUnixTimestamp converts a time.Time object to a Unix timestamp.

func TimestampToTime

func TimestampToTime(timestamp string) time.Time

func UnixMilliTimestamp

func UnixMilliTimestamp() int64

UnixMilliTimestamp returns the current Unix timestamp in milliseconds.

func UnixNanoTimestamp

func UnixNanoTimestamp() int64

UnixNanoTimestamp returns the current Unix timestamp in nanoseconds.

func UnixNanoToTime

func UnixNanoToTime(unixNanoTimestamp int64) time.Time

UnixNanoToTime converts a Unix timestamp in nanoseconds to a time.Time object.

func UnixTimeToTime

func UnixTimeToTime(unixTimestamp int64) time.Time

UnixTimeToTime converts a Unix timestamp to a time.Time object.

func UnixTimestamp

func UnixTimestamp() int64

UnixTimestamp returns the current Unix timestamp in seconds.

func UserSessionIdValue

func UserSessionIdValue(userId uint64, timestamp time.Time) string

UserSessionIdValue generates a session ID for a user based on the user's ID and the current time.

Types

This section is empty.

Directories

Path Synopsis
ipc

Jump to

Keyboard shortcuts

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