If there is a vet available, call first. You may be able to get an answer over the phone. It may be something simple, like it ate something, but you never know. If not, try calling a relative who loves dogs and might know what's going on. Maybe give it some water and cover it with a blanket. Get, I saw another answer. Though not a dog lover myself, some people can be pretty crass
Your dog might be having constipation because constipation is major cause of piles in dogs. Hard stool can cause damage to the anal blood vessels. But there should be a differential diagnosis because some other conditions that can cause swelling, bleeding or discharge from the anus. These are anal gland impaction, tumors and infection, rectal prolapse, anal abscess etc. Your vet can have differential diagnosis and offer accurate treatment.
If its a old dog he may have athritis, take him to vet as soon as possible, it might also be lameless
Get him to the vet as soon as you can. He could be getting bad enough that he might not make it. Hope this helps, good luck to you and the pup.
Wait until morning, it is after all a dog. S'not like they're is some crazy arss emergency, open all night, vet. It's just not happening. Sorry. If it dies before the place opens, that sucks, I'm pretty sure there's a pound near by.