Create a QR code with your Wi-Fi login details

Overview

Wi-Fi QR Code generator

Test Status PkgGoDev Go Report Card

Create a QR code with your Wi-Fi login details.

Use Google Lens or other application to scan it and connect automatically.

Installation

Download and install Go https://golang.org/doc/install.

Clone the repository:

git clone https://github.com/reugn/wifiqr.git

Build:

cd wifiqr
go build ./cmd/wifiqr

Usage

Usage of ./wifiqr:
  -enc string
        The wireless network encryption protocol (WEP, WPA, WPA2). (default "WPA2")
  -file string
        A png file to write the QR Code (prints to stdout if not set).
  -hidden string
        Hidden SSID true/false. (default "false")
  -key string
        A pre-shared key (PSK). You'll be prompted to enter the key if not set.
  -size int
        Size is both the image width and height in pixels. (default 256)
  -ssid string
        The name of the wireless network. You'll be prompted to enter the SSID if not set.
  -version
        Show version.

Usage example

./wifiqr -ssid some_ssid -key 1234 -file qr.png -size 128

License

MIT

Comments
  • UI Improvements & Refactoring

    UI Improvements & Refactoring

    UI Improvements & Refactoring

    The biggest UI improvement is the use of the prompui package for consuming user input. It's more interactive and performs dynamic validation.

    The UI now allows the user to select the encryption type from a list if the encryption option is invalid or an empty option is specified with -enc=. As before, if no encryption option is given, it defaults to WPA2 and the user is not prompted for the encryption type. I've tried to make these improvements without breaking the old UI flow (yet). One difference is invalid encryption protocols were allowed, but now they are limited to valid types.

    The main package has been mostly refactored. The highlights include:

    • Extraction of code to smaller functions to improvement maintainability, readability and hopefully to help accommodate future unit tests.
    • Move code in main to a new run function that returns an exit code. (Helps with future unit tests)
    • Remove the use of all global variables except injected version.
    • DRY the code.
      • SSID/password descriptions
      • .png extension
      • Validation code
    • Improve user facing text consistency.
    • Consistent use of error returns.
    • Validation of SSID maximum length.
    • Validation of encryption option.
    • Some unit test coverage.

    The core package now contains the type EncryptionType to help limit the input into the API and make the strings consistent. This particular implementation isn't ideal but works for now.

    Minor edits made to the README, mostly to conform to markdownlint.

    Note this PR changes the API a bit, but since it's a v0.x.x series of releases, I've assumed that's ok. The encryption protocol has changed from a type of string to EncryptionProtocol for both NewConfig and the Config struct.

    Unit testing will require a bit of dependency injection but before going through that, it'll be good to see how far this PR goes since I know it's unsolicited.

    opened by arcanericky 2
  • BUG: Does not accept spaces in SSID or Password

    BUG: Does not accept spaces in SSID or Password

    Greetings! Per my comment on reddit regarding a bug I found today:

    There seems to be a bug when using spaces in either the network name or the password:

    $ go run github.com/reugn/wifiqr/cmd/[email protected]
    Enter the name of the wireless network (SSID):
    one two three
    Enter the network key (password):
    
    (qr code omitted for brevity)
    
    bash-5.1$ three
    bash: three: command not found
    bash-5.1$ 
    

    Notice that it did not ask me for the password. Scanning the generated QR code shows that it used one as the SSID and two as the password.

    opened by davidpfarrell 2
  • Tool and dependency updates

    Tool and dependency updates

    Various Updates

    • Update Cobra from v1.2.1 to v.1.5.0
      • Because Viper is no longer pulled in, it should reduce the dependency tree
    • Update Go 1.18.x for building and testing
    • Update workflow actions to latest versions
    opened by arcanericky 1
  • Migrate the CLI from the standard library to Cobra

    Migrate the CLI from the standard library to Cobra

    This is a proposal in the form of a PR to migrate the CLI from the standard library to the Cobra package under the Apache License 2.0. Cobra is used by Kubernetes, the GitHub CLI, GoReleaser and many other popular projects.

    I can think of several benefits for this project with this migration:

    • Standard and familiar CLI interface like those of the projects mentioned above.
    • Long (--ssid) and short (-s) option formats.
    • Built in help output.
    • Automatic version option.
    • A more full featured flags library in general.

    A couple of reasons why you may not want to migrate:

    • Dragging yet another non-standard library into this project.
    • Larger executable (from about 3 mb to about 3.5 mb).
    • You have a problem with the Apache License 2.0.

    Command Options

    To transition to the combined long and short options, I've changed some of the options. These are simply my suggestions and should be carefully reviewed to ensure it's what you want. I can make any changes here that you'd like.

    Flag usage from the CLI changes a bit because of the long and short options.

    The changes are:

    • -file is now --output and -o which seems to be consistent with other utilities
    • -enc is now --protocol and -p because it is the protocol being specified
    • The short form of --ssid is -i for ID so it doesn't interfere with the -s (size) short option

    I'm personally not chained to any of this, so if you want the Cobra implementation but with different option names, let me know and I can change it, or you can approve and merge then change to your liking, etc.

    The No Password Edge Case

    When the user presents an empty key/password via the CLI (--enc ""), the user would still be prompted for password input instead of enabling no enryption protocol (NONE) which is what the user probably wants. This could probably be resolved using the old standard library but would require more than a couple lines of code. Cobra's pflag library makes this easy with the Changed method which has been implemented in this PR.

    README

    It has been updated with the new automatically generated Cobra help and the example command incantation updated with the new option names. For this PR, the new help output is:

    $ wifiqr --help
    wifiqr is a WiFi QR code generator
    
    It is used to create a QR code containing the login details such as
    the name, password, and encryption type. This QR code can be scanned
    using Google Lens or other QR code reader to connect to the network.
    It is Android and iOS compatible.
    
    If the options necessary for creating the QR code are not given on
    the command line, the user will be prompted for the information.
    
    Usage:
      wifiqr [flags]
    
    Flags:
      -h, --help              help for wifiqr
          --hidden            Hidden SSID
      -k, --key string        Wireless password (pre-shared key / PSK)
      -o, --output string     PNG file for output (default stdout)
      -p, --protocol string   Wireless network encryption protocol (WPA2, WPA, WEP, NONE). (default "WPA2")
      -s, --size int          Image width and height in pixels (default 256)
      -i, --ssid string       Wireless network name
      -v, --version           version for wifiqr
    

    And the version output example:

    $ wifiqr --version
    wifiqr version 0.9.9
    

    Why?

    I'm submitting all these PRs because I use this utility every week to connect to a protected wifi network. I'm a software developer that enjoys coding in Go. Put them together and I just wanted to give back. I also have the opinion that Cobra should be used to process user input for nearly every Go application. Thanks for accepting my previous PRs.

    opened by arcanericky 1
  • Support no encryption and escape SSID and password data

    Support no encryption and escape SSID and password data

    Background information for these changes can be found on ZXing's Wi-Fi Network config documentation section which is also referenced from the Wikipedia page and section on wifi networks.

    No Encryption

    No WiFi encryption is now supported. This is enabled on the command line with the -enc option which can be set to NONE, NOPASS, or empty with -enc "" and the user will not be prompted for a password. In the case where an invalid protocol is specified, the selection list now includes a NONE option after which the user is not prompted for a password. As before, the encryption protocol defaults to WPA2.

    Escape of SSID and Password

    Special characters in the SSID and password are now escaped with backslashes (\).

    Increased Unit Testing

    Unit tests have been added to support some of the new functionality, for building the string used to generate the QR code (buildSchema) and a few other functions.

    opened by arcanericky 0
  • Core code refinements

    Core code refinements

    • Remove use of variables that aren't really needed in InitCode
    • Eliminate the use of strings.Builder overhead
      • Also removes import of strings package
      • Speeds execution of buildSchema by 35%+
      • Significant decreased memory usage by buildSchema

    The refinement of buildSchema is probably not really useful when used from a command line utility, but if someone was to use this package as part of a REST API or other utility that performs this work repeatedly, it helps with memory use and runtime overhead.

    The output of benchcmp:

    benchmark                 old ns/op     new ns/op     delta
    Benchmark_buildSchema     200           125           -37.49%
    
    benchmark                 old allocs     new allocs     delta
    Benchmark_buildSchema     4              1              -75.00%
    
    benchmark                 old bytes     new bytes     delta
    Benchmark_buildSchema     120           48            -60.00%
    

    Function used for benchmarking:

    func Benchmark_buildSchema(b *testing.B) {
    	cfg := Config{
    		SSID:       "testssid",
    		Key:        "testkeytestkey",
    		Encryption: "WPA2",
    		Hidden:     false,
    	}
    
    	for i := 0; i < b.N; i++ {
    		buildSchema(&cfg)
    	}
    }
    
    opened by arcanericky 0
  • Release & GoReleaser Improvements

    Release & GoReleaser Improvements

    • Inject tagged version into released binary
      • No more need to modify source for each version
    • Reduce size of released binaries
      • -s: Omit symbol and debug info
      • -w: Omit DWARF symbol table
    • Builds for more platforms as might have been originally intended
    • Git ignore files in dist/
      • Helps with testing GoReleaser locally with a command such as goreleaser --skip-publish --rm-dist
    opened by arcanericky 0
  • Document use of go install in readme over go get

    Document use of go install in readme over go get

    go install (https://go.dev/ref/mod#go-install) is recommended as the way to install binaries rather than go get.

    If I run go get github.com/reugn/wifiqr from the README.md I see the following output:

    go: go.mod file not found in current directory or any parent directory.
    	'go get' is no longer supported outside a module.
    	To build and install a command, use 'go install' with a version,
    	like 'go install example.com/[email protected]'
    	For more information, see https://golang.org/doc/go-get-install-deprecation
    	or run 'go help get' or 'go help install'.
    

    What do you think about updating the readme to go install github.com/reugn/wifiqr/cmd/[email protected], it will install wifiqr to the go bin folder.

    Note: I tried go install github.com/reugn/[email protected] but get the following output:

    package github.com/reugn/wifiqr is not a main package
    

    Looking at other projects (e.g. https://github.com/knipferrc/fm) a simple main.go at the root should do the trick to make it work.

    opened by pfiaux 0
Releases(v0.3.2)
x-crafter is used to quickly create templates from your prototype, also come with a builder to quickly regenerate your code

XCrafter ?? x-crafter is used to quickly create templates from your prototype, also come with a builder to quickly regenerate your code. Install Using

Chi-Tai Vong 3 Nov 29, 2021
A Fyne login manager for linux desktop computers

Fin, the Fyne Login Manager This app is in it's very early stages and has only been tested with pam and systemd to log in users with a .xinitrc file.

Fyne.io 15 Oct 12, 2022
Test ssh login key acceptance without having the private key

ssh-key-confirmer This confirms if a SSH public key is listed as a authorized_key on a system Usage $ ssh-key-confirmer -i ./id_rsa.pub [email protected]

Ben Cox 204 Dec 30, 2022
Create a gRPC server from code generated by sqlc

sqlc-grpc Create a gRPC Server from the generated code by the awesome sqlc project. Dependencies Go 1.16 or superior protoc sqlc, protoc-gen-go and pr

Walter Wanderley 68 Dec 18, 2022
Send email and SMS broadcasts to your contacts. SMS are sent via your Android phone connected to your PC.

Polysender Send email and SMS broadcasts to your contacts. Polysender is a desktop application, so it does not require a complicated server setup. Ema

Charalampos Mitsakis 13 Aug 11, 2022
Simple application in Golang that retrieves your ip and updates your DNS entries automatically each time your IP changes.

DNS-Updater Simple application in Golang that retrieves your ip and updates your DNS entries automatically each time your IP changes. Motivation Havin

42_atomys 9 Mar 10, 2022
simplified helper to create http client calls to test your server

Overview Simplified creating http client calls for testing http servers or handlers. Cleanly build and execute http requests in tests so that you can

Adam Straughan 2 Nov 1, 2021
Read k8S-source-code notes, help quickly understand the K8S-code organization rules

K8S源码阅读笔记 以下笔记针对 kubernetes V1.23.1(截至2022年01月01日最新版本),并不保证对其它版本的有效性 一、架构图 二、阅读前准备 由于kubernetes项目巧妙的设计和代码高度的封装性,建议在阅读代码前,尽可能的进行以下内容的准备: 1. 编程知识配备 编程语准

kubernetes-based edge-cloud solution 0 Feb 16, 2022
JPRQ Customizer is a customizer that helps to use the JPRQ server code and make it compatible with your own server with custom subdomain and domain

JPRQ Customizer is a customizer that helps to use the JPRQ server code and make it compatible with your own server with custom subdomain and domain.You can upload the generated directory to your web server and expose user localhost to public internet. You can use this to make your local machine a command center for your ethical hacking purpose ;)

Abir Ghosh 1 Jan 19, 2022
gh is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code

gh is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code

frenchy77 0 Jan 24, 2022
A server that proxies requests and uses fhttp & my fork of CycleTLS to modify your clienthello and prevent your requests from being fingerprinted.

TLS-Fingerprint-API A server that proxies requests and uses my fork of CycleTLS & fhttp (fork of net/http) to prevent your requests from being fingerp

null 176 Jan 7, 2023
A tool helps connect to your AriPods when sound playing in your Mac

Auto connect to airpods this tool helps connect to your AriPods when sound playing in your Mac. dependencenes SwitchAudioSource $ brew install switcha

Fndroid 2 Dec 9, 2021
Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com).

Go Modules Remote Import Path Proxy Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com). For example Uber (buil

Stefan Kürzeder 2 Nov 2, 2021
Traefik config validator: a CLI tool to (syntactically) validate your Traefik configuration filesTraefik config validator: a CLI tool to (syntactically) validate your Traefik configuration files

Traefik Config Validator Note This is currently pre-release software. traefik-config-validator is a CLI tool to (syntactically) validate your Traefik

Thomas Klinger 0 Dec 16, 2021
Peoplenect - Keep track of all your professional connections on your machine

Peoplenect Keep track of all your professional connections. TODO Create database

Martin Heberling 0 Jun 2, 2022
The fastest way to create self-hosted exit-servers

inletsctl - the fastest way to create self-hosted exit-servers inletsctl automates the task of creating an exit-server (tunnel server) on public cloud

inlets 428 Dec 15, 2022
kcp is a prototype of a Kubernetes API server that is not a Kubernetes cluster - a place to create, update, and maintain Kube-like APis with controllers above or without clusters.

kcp is a minimal Kubernetes API server How minimal exactly? kcp doesn't know about Pods or Nodes, let alone Deployments, Services, LoadBalancers, etc.

Prototype of Future Kubernetes Ideas 1.8k Jan 6, 2023