Spyke

Posts

golang·Golangbytapdattl

Go Modules in Local/Private Forgejo Instances

Bit of a newbie question here, but I've set up a local Forgejo server in my homelab that I'm using for personal projects. I've created some modules that I want to be able to reference in other local projects.

Trying to run

go get code.mydomainname.com/tapdattl/test

returns

go: downloading code.mydomainname.com/tapdattl/test v1.0.0
go: code.mydomainname.com/tapdattl/[email protected]: verifying module: code.mydomainname.com/tapdattl/[email protected]: reading https://sum.golang.org/lookup/code.mydomainname.com/tapdattl/[email protected]: 404 Not Found
        server response: not found: code.mydomainname.com/tapdattl/[email protected]: unrecognized import path "code.mydomainname.com/tapdattl/test": https fetch: Get "https://code.mydomainname.com/tapdattl/test?go-get=1": dial tcp <my netbird ip address>:443: connect: connection refused

However I know my Forgejo server is up, and I can push to it and clone from it and do all the normal Git workflows. But Go apparently can't talk to it.

Can anyone explain what's going on?

Thanks!!

View original on lemmy.world
javascript·JavaScriptbytapdattl

Client-Side Request Deduplicator Help (Solved)

Solved So turns out I need to store the original response and return clones. I've updated the code below to reflect that change. But feel free to use the below to deduplicate requests.

Hello,

I'm working on a small class to deduplicate API request calls. The basic function being a map of request path -> request promise. The issue I am running into is that on sequential calls I get a "response body has already been consumed" error.

From what I've read, I need to use response: (await res).clone() in the call to this.queryMap.set, however when I do that the map doesn't get updated in time to cache the calls (I think) and all 10 queries get sent to the API endpoint without being cached.

Any ideas on what I need to do?

class Deduplicator {
    queryMap = null;

    constructor() {
        this.queryMap = new Map();
    }

    async get(query, ttl = 10) {
        let now = Temporal.Now.instant();
        let cacheCheck = this.queryMap.get(query);
        if (cacheCheck == undefined || now.since(Temporal.Instant.from(cacheCheck.at)).seconds > ttl) {
            console.log("Cache miss on ", query)
            const res = fetch(query, {
                method: "GET",
            });
            this.queryMap.set(query, {
                at: now,
                response: res,
            })
            return (await res).clone(); //Previously just returned res
        } else {
            console.log("Cached response of ", query);
            return (await cacheCheck.response).clone(); //Previously just returned cacheCheck.response
        }
    }
}

Example:

let deduplicator = new Deduplicator();
for( let i = 0; i < 10; i++){
   let a = (await deduplicator.get("https://jsonplaceholder.typicode.com/todos/3", 10)).json();
   console.log('res: ', a);
}
View original on lemmy.world
golang·Golangbytapdattl

Idiomatic Go Question

Given the following short function

func example(foo string) error {
    if bar, err := doSomething(foo); err != nil {
        return err
    } else {
        doSomethingElse(bar)
    }
    return nil
}

Why does the linter recommend I change the if block to

    var bar whateverType
    if bar, err = doSomething(foo); err != nil {
        return err
    }
    doSomethingElse(bar)
    return nil
}

In my mind the former example restricts the bar variable to the smallest scope that is needed, and more clearly identifies doSomethingElse as something that should only happen if err != nil.

I know it's redundant, but now if I want to change it to an else if ... chain I don't have to worry about accidentally including or excluding code from that block, I already know exactly what's supposed to be in it. I just feel like it's a safer programming practice.

But looking forward to other opinions and discussion. Thanks!

View original on lemmy.world
framework·Frameworkbytapdattl

Power-On Hardware Issue

Hello all, hoping to get a little assistance on a hardware issue I'm having. I've got an older framework laptop (Batch 5, ~Nov. 2021), and recently it's been having issues powering on. Regardless of the laptop's charge, it will not power on unless it's plugged in. As soon as I past the POST, I can unplug it and it will continue on battery, but in order to get it to actually power on it needs to be plugged in.

Not sure what could be causing this, maybe just a weak battery? Battery health is at 84%. Looking forward to ya'lls thoughts. Thanks!

View original on lemmy.world
programming·Programmingbytapdattl

Best Practices for Encrypted Search

Task

I'm working on my final project for school, we are supposed to make a web app of our choosing and there has to be specific features in it. One of it is all data must be encrypted, and the other is that we have to have a search functionality. My app (A customer support framework) has a ticket functionality where customers can submit help request tickets, the contents of these tickets need to be encrypted at rest, at the same time admins need to be able to search contents of tickets.

Current Plan

My current plan is to store an AES-256 encrypted copy of the message message.content to meet the encrypted requirement, and also store a tokenized and hashed version of the message message.hashed to meet the searchability requirement.

The tokenization/hashing method will be:

  • strip the message to alphanumeric + whitespace ([a-zA-Z0-9 ])
  • tokenize by splitting the message by whitespace,
  • SHA-256 each token,
  • rejoin all the hashed tokens into a space seperated string and stored in the message.hashed field.

Thus this is a test string becomes <hash of this> <hash of is> <hash of a> <hash of test> <hash of string>

When the user searches their search string goes through all of the steps in the tokenization/hashing method, then we query the message table for message.hashed LIKE %%<hashed string>%% and if my thinking is right, we should be able to find it.

Concerns

  • Statistical analysis of hashed tokens
    • I really don't see a way around this, to make the string searchable the hashing needs to be predictable.
  • message.hashed field could potentially be huge, if each word is getting a SHA256 hash, a large message could result in a very large hash string
    • maybe we just store the last 4 of the hash?
      • This would increase collisions, but the likelihood of multiple last 4's colliding in a given search string should be pretty dang small, and any collisions would likely not be valid language.
      • Would this help with the statistical analysis concern? Increasing collisions would decrease the effectiveness of statistical analysis. It would be a performance hit, but after returning all matches against the hashes I could decrypt the message.content data and search the raw search query against the unencrypted text and remove any incorrect returns caused by collisions.

I'm interested in hearing everyone's thoughts, am I being logical in my reasoning?

View original on lemmy.world
privacy·Privacybytapdattl

Government Surveillance on Chinese vs US made phones

Question that I've been mulling over recently: My threat model dictates that I'm more likely to be surveilled by the US government than by the Chinese government. We can also assume that the Chinese government is not going to cooperate with the US government in any investigations of potential activist activity.

Would it not be best, then, to use a Chinese-made phone that, even though we know that information is going to China, we can also assume that any backdoors in the system are unknown to the US Gov?

I'm interested in everyone's take on this.

View original on lemmy.world
linux·Linuxbytapdattl

Recommendations on Linux Friendly PDF Software

Hey all,

My father's business requires him to work a lot with PDF forms, combine PDF files, convert scanned pictures to files, etc.

I've found Master PDF editor, but I've found it to be buggy -- specifically when trying to create a new PDF from multiple files the program errors out saying it can't create the file.

I've also tried running Foxxit PDF editor through WINE but that's abysmal.

Any recommendations on Linux native software paid or FOSS, that can fill forms, create/combine PDFs, and do basic edition (rotating pages, etc) that my 70 year old dad can learn to use?

I moved him away from Windows with the Windows 11 debacle, and he's liked Linux so far except for this one issue

Thanks all for your help?

***** EDIT *****

Thanks all for your responses, I'll be trying out StirlingpPDF, PDFSam, OnlyOffice, and re-trying MasterPDF editor over the holidays while I have some 1:1 time with my dad. Tl;Dr: playing family IT and switching your parents to Linux is rough 😂

View original on lemmy.world
selfhosted·Selfhostedbytapdattl

Local NetBird Network for Zero Trust network, accessible from WAN

I'm re-setting up my HomeLab and one of the things I'm trying to learn about on this go-around is Zero Trust networking. To accomplish this I am planning on using NetBird's mesh overlay network. I would like all of my services to use the NetBird mesh network at all times, whether they are communicating within my homelab's LAN or I am accessing them from outside via the greater internet.

I have successfully set up the NetBird management interface on a Hetzner VPS, however the issue I run into is if I lose internet access at home, none of my services are able to function as they can no longer reach the management interface. However, if I self host the management interface in my homelab, I am unable to access it from outside my home LAN.

I've identified 2 solutions that could solve this:

  1. Self host the management interface and set up a Cloudflare tunnel to the management interface, which would allow access from outside my home network.

  2. Self host the management interface, then set up a wireguard proxy/tunnel on a VPS that forwards traffic to my management interface (Similar in my mind to option 1, but not relying on Cloudflare)

What are your thoughts? Any other ideas?

I appreciate your comments/criticisms!

View original on lemmy.world
selfhosted·Selfhostedbytapdattl

Proxmox running TrueNAS and NextCloud or Nextcloud on TrueNAS via Docker?

As the title states, how would you set it up? I've got an HP EliteDesk G5, what are the strengths and weaknesses of either:

  • ProxMox with one VM running TrueNAS and another VM running Nextcloud
  • TrueNAS on bare metal with Nextcloud running in docker
  • Some other setup

I'd like to be able to easily expand and backup the storage available to Nextcloud as needed and I'd also like the ability to add additional VMs/containers/services as needed

View original on lemmy.world
selfhosted·Selfhostedbytapdattl

What do you use to manage operating system images for installation on new laptops and workstations?

I'm wanting to create a centralized repository to keep base images of operating systems to be installed on new laptops or workstations bought/used in my household with my local CA already installed, configured to authenticate with my local FreeIPA instance, network configurations already configured, etc.

What do you all use to accomplish this? I'm only free/libre/open source software for my home lab, so that's a requirement as well.

Ideally I'd like to be able to buy a computer, flash the latest and greatest from my repository onto a bootable thumb drive, install onto the computer, and be ready to go without any further configuration.

View original on lemmy.world
hardware·Hardwarebytapdattl

Installing NIC in HP EliteDesk 800 G3 Mini

I recently bought a refurbished HP EliteDesk mini to act as a server in my homelab. It, unfortunately, only has 1 Ethernet port. Does anyone have any experience in adding another Ethernet port to this system? It has 3 Display ports, which I definitely don't need, so space-wise I was thinking of replacing a couple of them, but I'm not familiar with the process.

Any advice? Is this even doable?

View original on lemmy.world

You reached the end